mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
Issue #15101: Make pool finalizer avoid joining current thread.
This commit is contained in:
parent
da7a6e7da0
commit
f29ec4b0c8
2 changed files with 8 additions and 3 deletions
|
@ -493,7 +493,8 @@ class Pool(object):
|
|||
# We must wait for the worker handler to exit before terminating
|
||||
# workers because we don't want workers to be restarted behind our back.
|
||||
debug('joining worker handler')
|
||||
worker_handler.join()
|
||||
if threading.current_thread() is not worker_handler:
|
||||
worker_handler.join()
|
||||
|
||||
# Terminate workers which haven't already finished.
|
||||
if pool and hasattr(pool[0], 'terminate'):
|
||||
|
@ -503,10 +504,12 @@ class Pool(object):
|
|||
p.terminate()
|
||||
|
||||
debug('joining task handler')
|
||||
task_handler.join()
|
||||
if threading.current_thread() is not task_handler:
|
||||
task_handler.join()
|
||||
|
||||
debug('joining result handler')
|
||||
result_handler.join()
|
||||
if threading.current_thread() is not result_handler:
|
||||
result_handler.join()
|
||||
|
||||
if pool and hasattr(pool[0], 'terminate'):
|
||||
debug('joining pool workers')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue