Arkadiusz Miśkiewicz <[email protected]> added the comment:
I've applied pull request patch (which looks a bit weird to me, removes
something then adds the same thing back etc
https://patch-diff.githubusercontent.com/raw/python/cpython/pull/19009.patch).
Essentially the change is:
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
index b223d6aa72..8bd9608b0e 100644
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -682,7 +682,15 @@ class Pool(object):
# this is guaranteed to only be called once
util.debug('finalizing pool')
- worker_handler._state = TERMINATE
+ # Explicitly do the cleanup here if it didn't come from terminate()
+ # (required for if the queue will block, if it is already closed)
+ if worker_handler._state != TERMINATE:
+ # Notify that the worker_handler state has been changed so the
+ # _handle_workers loop can be unblocked (and exited) in order to
+ # send the finalization sentinel all the workers.
+ worker_handler._state = TERMINATE
+ change_notifier.put(None)
+
task_handler._state = TERMINATE
util.debug('helping task handler/workers to finish')
Unfortunately test case from first message in this bug report still hangs for
me with this applied.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39360>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com