You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
concurrent.futures Executor.map cancels other futures when one raises an exception #108518
I am confident this is a bug in CPython, not a bug in a third-party project
I have searched the CPython issue tracker,
and am confident this bug has not been reported before
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.11.5 (main, Aug 24 2023, 12:23:19) [GCC 11.4.0]
A clear and concise description of the bug:
While using concurrent.futures.ProcessPoolExecutor.map when one of the calls to the function raises an exception, per the documentation, this exception is raised when the value is retrieved from the iterator returned by the call to concurrent.futures.ProcessPoolExecutor.map. However, it was seen that the iterator also terminates when the exception is retrieved from the iterator which is unexpected and doesn't align with what the built-in map function does. This means that other values fetched in separate calls cannot be retrieved with this method.
You cannot return to the generator function after raising any exception inside, and current behavior obviously contradicts the documentation. The problem applies to all supported python versions.
I can imagine the solution based on making result_iterator a class with __next__ method, however, this needs some insights from concurrent.futures experts (@gpshead) first: such changes will be breaking.
Activity
sterliakov commentedon Aug 29, 2023
Caused by
cpython/Lib/concurrent/futures/_base.py
Lines 612 to 625 in d08d49d
You cannot return to the generator function after raising any exception inside, and current behavior obviously contradicts the documentation. The problem applies to all supported python versions.
I can imagine the solution based on making
result_iteratora class with__next__method, however, this needs some insights fromconcurrent.futuresexperts (@gpshead) first: such changes will be breaking.gh-108518: Do not cancel remaining calls in Executor.map() on error (G…
serhiy-storchaka commentedon Aug 11, 2026
The behavior changed in 3.16. This is a new feature.
pythongh-108518: Do not cancel remaining calls in Executor.map() on e…
gh-155852: Do not cancel remaining Executor.map calls on a callable's…