Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f29ec4b

Browse files
committed
Issue #15101: Make pool finalizer avoid joining current thread.
1 parent da7a6e7 commit f29ec4b

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

Lib/multiprocessing/pool.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ def _terminate_pool(cls, taskqueue, inqueue, outqueue, pool,
493493
# We must wait for the worker handler to exit before terminating
494494
# workers because we don't want workers to be restarted behind our back.
495495
debug('joining worker handler')
496-
worker_handler.join()
496+
if threading.current_thread() is not worker_handler:
497+
worker_handler.join()
497498

498499
# Terminate workers which haven't already finished.
499500
if pool and hasattr(pool[0], 'terminate'):
@@ -503,10 +504,12 @@ def _terminate_pool(cls, taskqueue, inqueue, outqueue, pool,
503504
p.terminate()
504505

505506
debug('joining task handler')
506-
task_handler.join()
507+
if threading.current_thread() is not task_handler:
508+
task_handler.join()
507509

508510
debug('joining result handler')
509-
result_handler.join()
511+
if threading.current_thread() is not result_handler:
512+
result_handler.join()
510513

511514
if pool and hasattr(pool[0], 'terminate'):
512515
debug('joining pool workers')

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Core and Builtins
7070
Library
7171
-------
7272

73+
- Issue #15101: Make pool finalizer avoid joining current thread.
74+
7375
- Issue #15036: Mailbox no longer throws an error if a flush is done
7476
between operations when removing or changing multiple items in mbox,
7577
MMDF, or Babyl mailboxes.

0 commit comments

Comments
 (0)