From: Richard Oudkerk Date: Mon, 18 Jun 2012 14:37:31 +0000 (+0100) Subject: Issue #15101: Make pool finalizer avoid joining current thread X-Git-Tag: v2.7.4rc1~752 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4215d2738a44be9eca09eb7b48c31ed805c8fb60;p=python Issue #15101: Make pool finalizer avoid joining current thread --- diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py index 170aa7f7c7..00c904a8a7 100644 --- a/Lib/multiprocessing/pool.py +++ b/Lib/multiprocessing/pool.py @@ -489,7 +489,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(1e100) # Terminate workers which haven't already finished. if pool and hasattr(pool[0], 'terminate'): @@ -499,10 +500,12 @@ class Pool(object): p.terminate() debug('joining task handler') - task_handler.join(1e100) + if threading.current_thread() is not task_handler: + task_handler.join(1e100) debug('joining result handler') - result_handler.join(1e100) + if threading.current_thread() is not result_handler: + result_handler.join(1e100) if pool and hasattr(pool[0], 'terminate'): debug('joining pool workers') diff --git a/Misc/NEWS b/Misc/NEWS index a11c488c3e..11fb95fc2a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -67,6 +67,8 @@ Core and Builtins Library ------- +- Issue #15101: Make pool finalizer avoid joining current thread. + - Issue #15054: A bug in tokenize.tokenize that caused string literals with 'b' and 'br' prefixes to be incorrectly tokenized has been fixed. Patch by Serhiy Storchaka.