From: Richard Oudkerk Date: Mon, 18 Jun 2012 14:54:57 +0000 (+0100) Subject: Issue #15101: Make pool finalizer avoid joining current thread. X-Git-Tag: v3.3.0b1~197^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f29ec4b0c89bbb3a4ee4549b3b4a8535d040833f;p=python Issue #15101: Make pool finalizer avoid joining current thread. --- diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py index ccee9612d4..7502ff89f4 100644 --- a/Lib/multiprocessing/pool.py +++ b/Lib/multiprocessing/pool.py @@ -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') diff --git a/Misc/NEWS b/Misc/NEWS index 02064c0a15..5c1e81ae63 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -70,6 +70,8 @@ Core and Builtins Library ------- +- Issue #15101: Make pool finalizer avoid joining current thread. + - Issue #15036: Mailbox no longer throws an error if a flush is done between operations when removing or changing multiple items in mbox, MMDF, or Babyl mailboxes.