[docs] [issue13139] multiprocessing.map skips finally blocks

Antoine Pitrou report at bugs.python.org
Sat Oct 15 16:31:29 CEST 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

As mentioned in http://docs.python.org/dev/library/multiprocessing#multiprocessing.pool.AsyncResult.get
“If the remote call raised an exception then that exception will be reraised by get().”

map() is just map_async() followed by a get() call on the result.
Also, worker processes are called in daemon mode, which explains that children get killed as soon as the parent exits.

If you rephrase your example as:

try:
    Pool(3).map(Process, ['1','2','3'])
finally:
    sleep(1)

then all the children's finally clauses get a chance to be executed before the parent exits.

I would therefore call it "not a bug", although you might add a sentence in the map() documentation stating that an exception is raised as soon as one of the worker fails.

----------
assignee:  -> docs at python
components: +Documentation
nosy: +docs at python, pitrou

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13139>
_______________________________________


More information about the docs mailing list