python - Multiprocessing Shared Array/Variable Windows is not updated in the process -


i read various posts shared array , update in processes: sharing numpy arrays in python multiprocessing pool

for reasons, in windows, following variable v not updated @ put name in global file, common code files, same result ):

the result 0 instead of 50*10 (ie variable v not updated @ all....)

 import time  multiprocessing import process, value, lock  import multiprocessfunc mpf #put multi process function loop there   if __name__ == '__main__':      v = value('i', 0)      lock = lock()      procs = [process(target=mpf.func, args=(v, lock)) in range(10)]       p in procs: p.start()      p in procs: p.join()       print(v.value) 

in multiprocessfunc file, put one:

 def func(val, lock):      in range(50):          time.sleep(0.01)          lock:              val.value += 1 

what think ?

update: if use pool.map return average/sum value, works well. case when passing value/shared array, processes not updating global variable....

i got same issue when setup share array. array not updated.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -