Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25541 > unrolled thread

multiprocessing: apply_async with different callbacks

Started byAndré Panisson <panisson@di.unito.it>
First post2012-07-17 23:44 +0200
Last post2012-07-17 23:44 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  multiprocessing: apply_async with different callbacks André Panisson <panisson@di.unito.it> - 2012-07-17 23:44 +0200

#25541 — multiprocessing: apply_async with different callbacks

FromAndré Panisson <panisson@di.unito.it>
Date2012-07-17 23:44 +0200
Subjectmultiprocessing: apply_async with different callbacks
Message-ID<mailman.2250.1342561966.4697.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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é

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web