]> granicus.if.org Git - python/commitdiff
Make Finalize reserve a reference to os.getpid in case called at shutdown
authorRichard Oudkerk <shibturn@gmail.com>
Mon, 4 Jun 2012 17:58:59 +0000 (18:58 +0100)
committerRichard Oudkerk <shibturn@gmail.com>
Mon, 4 Jun 2012 17:58:59 +0000 (18:58 +0100)
Lib/multiprocessing/util.py

index 16ded512218b2850b5f2588ae4481de00873fce1..48abe383fa4b3707dc9cb7b801a1005addb95103 100644 (file)
@@ -170,7 +170,7 @@ class Finalize(object):
                  # Need to bind these locally because the globals can have
                  # been cleared at shutdown
                  _finalizer_registry=_finalizer_registry,
-                 sub_debug=sub_debug):
+                 sub_debug=sub_debug, getpid=os.getpid):
         '''
         Run the callback unless it has already been called or cancelled
         '''
@@ -179,7 +179,7 @@ class Finalize(object):
         except KeyError:
             sub_debug('finalizer no longer registered')
         else:
-            if self._pid != os.getpid():
+            if self._pid != getpid():
                 sub_debug('finalizer ignored because different process')
                 res = None
             else: