[docs] Bug: multiprocessing documentation
naroom at gmail.com
Tue May 21 20:14:36 CEST 2013
126.96.36.199. Synchronization between processes
Sample code doesn't work, as processes may exit before releasing the lock.
Adding a join() on each process fixes the problem. Corrected code below:
from multiprocessing import Process, Lock
def f(l, i):
#single process executes the block at a time
print 'hello world', i
if __name__ == '__main__':
lock = Lock()
#spawn 10 processes, each with an arg that says their index
for num in range(10):
p = Process(target=f, args=(lock, num))
Thanks for maintaining the doc, for the betterment of all mankind!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the docs