]> 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:54:57 +0000 (15:54 +0100)
committerRichard Oudkerk <shibturn@gmail.com>
Mon, 18 Jun 2012 14:54:57 +0000 (15:54 +0100)
Lib/multiprocessing/pool.py
Misc/NEWS

index ccee9612d4cc2bd7a226e5dcd0d56a8f166ab569..7502ff89f432f64763bcbf70634eac0daa349b32 100644 (file)
@@ -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')
index 02064c0a15f73f842ceabb0d601062d3c90e179f..5c1e81ae6309b80fbdf212a99cfeacc0c7aedc9e 100644 (file)
--- 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.