How i can share an array as in the code below with an array and not a single value (in this example there is a counter as you can see)?
How i can append and remove elements from the array?
class mp_counter(object):
def __init__(self, initval=0):
self.val = multiprocessing.Value('i', initval)
self.lock = multiprocessing.Lock()
def increment(self):
with self.lock:
self.val.value += 1
def decrement(self):
with self.lock:
self.val.value -= 1
def value(self):
with self.lock:
return self.val.value
counter = mp_counter(0)
proc = threading.Thread(target=start_processes,kwargs={"counter":counter})
proc.daemon = True
proc.start()
Thank you in advance
Queue? Check out this example: docs.python.org/2/library/…shared_array_base = multiprocessing.Array(ctypes.c_double, 10) shared_array = np.ctypeslib.as_array(shared_array_base.get_obj())