mirror of
https://github.com/python/cpython.git
synced 2025-09-01 22:47:59 +00:00
Revise to use atexit instead of monkeying with sys.exitfunc directly.
This commit is contained in:
parent
def003845b
commit
7b4fc17c6d
1 changed files with 2 additions and 9 deletions
|
@ -462,11 +462,8 @@ class _MainThread(Thread):
|
||||||
_active_limbo_lock.acquire()
|
_active_limbo_lock.acquire()
|
||||||
_active[_get_ident()] = self
|
_active[_get_ident()] = self
|
||||||
_active_limbo_lock.release()
|
_active_limbo_lock.release()
|
||||||
try:
|
import atexit
|
||||||
self.__oldexitfunc = _sys.exitfunc
|
atexit.register(self.__exitfunc)
|
||||||
except AttributeError:
|
|
||||||
self.__oldexitfunc = None
|
|
||||||
_sys.exitfunc = self.__exitfunc
|
|
||||||
|
|
||||||
def _set_daemon(self):
|
def _set_daemon(self):
|
||||||
return 0
|
return 0
|
||||||
|
@ -480,10 +477,6 @@ class _MainThread(Thread):
|
||||||
while t:
|
while t:
|
||||||
t.join()
|
t.join()
|
||||||
t = _pickSomeNonDaemonThread()
|
t = _pickSomeNonDaemonThread()
|
||||||
if self.__oldexitfunc:
|
|
||||||
if __debug__:
|
|
||||||
self._note("%s: calling exit handler", self)
|
|
||||||
self.__oldexitfunc()
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
self._note("%s: exiting", self)
|
self._note("%s: exiting", self)
|
||||||
self._Thread__delete()
|
self._Thread__delete()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue