]> granicus.if.org Git - python/commitdiff
Issue #15101: Make pool finalizer avoid joining current thread
authorRichard Oudkerk <shibturn@gmail.com>
Mon, 18 Jun 2012 14:37:31 +0000 (15:37 +0100)
committerRichard Oudkerk <shibturn@gmail.com>
Mon, 18 Jun 2012 14:37:31 +0000 (15:37 +0100)
Lib/multiprocessing/pool.py
Misc/NEWS

index 170aa7f7c7f062cbab7b687520c89bf4e435cef4..00c904a8a731ad4b3fc2f07293307176903fa357 100644 (file)
@@ -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')
index a11c488c3e48425cf0038df01f8aaf9fe41c5b8c..11fb95fc2a31a33d6693f661424c48f2f34cddd3 100644 (file)
--- 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.