Posts

Showing posts with the label multiprocessing

Trying to copy back elements in Array works with integers but not with strings in Multiprocessing Python module

Trying to copy back elements in Array works with integers but not with strings in Multiprocessing Python module I am trying to write a process which does some computation on an Array filled with strings using the multiprocessing module. However, I am not able to get back the results. This is just a minimalist code example: from multiprocessing import Process, Value, Array from ctypes import c_char_p # Process def f(n, a): for i in range(0,10): a[i] = "test2".encode('latin-1') if __name__ == '__main__': # Set up array arr = Array(c_char_p, range(10)) # Fill it with values for i in range(0,10): arr[i] = "test".encode('latin-1') x = for i in range(0,10): num = Value('d', float(i)*F) p = Process(target=f, args=(num, arr,)) x.append(p) p.start() for p in x: p.join() # THis works print(num.value) # This will not give out anything print(ar...