summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing/pool.py
diff options
context:
space:
mode:
authorCharles-François Natali <cf.natali@gmail.com>2016-02-10 22:58:18 (GMT)
committerCharles-François Natali <cf.natali@gmail.com>2016-02-10 22:58:18 (GMT)
commit78f55ffc63ba637ffa4a07ca869f451e680b002a (patch)
tree989eba7361182ad95629aba10c19fc81c3720037 /Lib/multiprocessing/pool.py
parenteaf8ebc139b22efa3ecb844f320908aee80c77bd (diff)
downloadcpython-78f55ffc63ba637ffa4a07ca869f451e680b002a.zip
cpython-78f55ffc63ba637ffa4a07ca869f451e680b002a.tar.gz
cpython-78f55ffc63ba637ffa4a07ca869f451e680b002a.tar.bz2
Issue #23992: multiprocessing: make MapResult not fail-fast upon exception.
Diffstat (limited to 'Lib/multiprocessing/pool.py')
-rw-r--r--Lib/multiprocessing/pool.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
index 6d25469..ffdf426 100644
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -638,22 +638,26 @@ class MapResult(ApplyResult):
self._number_left = length//chunksize + bool(length % chunksize)
def _set(self, i, success_result):
+ self._number_left -= 1
success, result = success_result
- if success:
+ if success and self._success:
self._value[i*self._chunksize:(i+1)*self._chunksize] = result
- self._number_left -= 1
if self._number_left == 0:
if self._callback:
self._callback(self._value)
del self._cache[self._job]
self._event.set()
else:
- self._success = False
- self._value = result
- if self._error_callback:
- self._error_callback(self._value)
- del self._cache[self._job]
- self._event.set()
+ if not success and self._success:
+ # only store first exception
+ self._success = False
+ self._value = result
+ if self._number_left == 0:
+ # only consider the result ready once all jobs are done
+ if self._error_callback:
+ self._error_callback(self._value)
+ del self._cache[self._job]
+ self._event.set()
#
# Class whose instances are returned by `Pool.imap()`