mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #10332: multiprocessing: fix a race condition when a Pool is closed
before all tasks have completed.
This commit is contained in:
parent
d6ca6c2b32
commit
f8859e1808
3 changed files with 22 additions and 1 deletions
|
@ -321,7 +321,11 @@ class Pool(object):
|
|||
|
||||
@staticmethod
|
||||
def _handle_workers(pool):
|
||||
while pool._worker_handler._state == RUN and pool._state == RUN:
|
||||
thread = threading.current_thread()
|
||||
|
||||
# Keep maintaining workers until the cache gets drained, unless the pool
|
||||
# is terminated.
|
||||
while thread._state == RUN or (pool._cache and thread._state != TERMINATE):
|
||||
pool._maintain_pool()
|
||||
time.sleep(0.1)
|
||||
# send sentinel to stop workers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue