Index: Lib/threading.py =================================================================== --- Lib/threading.py (revision 27300) +++ Lib/threading.py (revision 29956) @@ -741,10 +741,14 @@ class _MainThread(Thread): + def waitForThreadsOnExit(self): + return True + def __init__(self): Thread.__init__(self, name="MainThread") self._Thread__started.set() self._set_ident() + self.waitForThreadsOnExitFunc = self.waitForThreadsOnExit _active_limbo_lock.acquire() _active[_get_ident()] = self _active_limbo_lock.release() @@ -754,15 +758,18 @@ def _exitfunc(self): self._Thread__stop() + t = _pickSomeNonDaemonThread() if t: - if __debug__: + wait = self.waitForThreadsOnExitFunc() + if wait and __debug__: self._note("%s: waiting for other threads", self) - while t: + while t and wait: t.join() t = _pickSomeNonDaemonThread() if __debug__: self._note("%s: exiting", self) + self._Thread__delete() def _pickSomeNonDaemonThread():