mirror of
https://github.com/python/cpython.git
synced 2025-10-06 07:02:33 +00:00
Issue #23992: multiprocessing: make MapResult not fail-fast upon exception.
This commit is contained in:
parent
eaf8ebc139
commit
78f55ffc63
3 changed files with 38 additions and 8 deletions
|
@ -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()`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue