multiprocessing: apply_async with different callbacks
André Panisson
panisson at di.unito.it
Tue Jul 17 17:44:27 EDT 2012
Hi all,
I'm having a strange behavior when executing the following script:
---------------------------
import multiprocessing
def f(i):
return i
p = multiprocessing.Pool()
for i in range(20):
def c(r):
print r, i
p.apply_async(f, (i,) , callback=c)
p.close()
p.join()
---------------------------
Result:
0 6
1 11
2 13
3 15
4 15
5 19
etc....
It seems that the callbacks of all submitted tasks are being overridden
with the last callback submitted by apply_async.
Is this the right behaviour or I am stumbling in some issue? I'm using
Python 2.7.3 @ Ubuntu 12.04
Regards,
André
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3878 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20120717/6e9936a3/attachment.bin>
More information about the Python-list
mailing list