]> granicus.if.org Git - python/commitdiff
Revise to use atexit instead of monkeying with sys.exitfunc directly.
authorFred Drake <fdrake@acm.org>
Fri, 18 Aug 2000 15:50:54 +0000 (15:50 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 18 Aug 2000 15:50:54 +0000 (15:50 +0000)
Lib/threading.py

index fb2eb21778bf3159459399747ac827116d68b86a..4921f0e5c7bf0fc4de25224de7b2199410b3ed91 100644 (file)
@@ -462,11 +462,8 @@ class _MainThread(Thread):
         _active_limbo_lock.acquire()
         _active[_get_ident()] = self
         _active_limbo_lock.release()
-        try:
-            self.__oldexitfunc = _sys.exitfunc
-        except AttributeError:
-            self.__oldexitfunc = None
-        _sys.exitfunc = self.__exitfunc
+        import atexit
+        atexit.register(self.__exitfunc)
 
     def _set_daemon(self):
         return 0
@@ -480,10 +477,6 @@ class _MainThread(Thread):
         while t:
             t.join()
             t = _pickSomeNonDaemonThread()
-        if self.__oldexitfunc:
-            if __debug__:
-                self._note("%s: calling exit handler", self)
-            self.__oldexitfunc()
         if __debug__:
             self._note("%s: exiting", self)
         self._Thread__delete()