Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions magicbus/plugins/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
except AttributeError:
max_files = 1024

if hasattr(threading.currentThread(), 'is_alive'):
is_alive = lambda t: t.is_alive()
else:
is_alive = lambda t: t.isAlive()

from magicbus import plugins


Expand All @@ -39,13 +44,17 @@ class ThreadWait(plugins.SimplePlugin):

def EXIT(self):
# Waiting for ALL child threads to finish is necessary on OS X.
# See https://github.com/cherrypy/cherrypy/issues/581.
# See http://www.cherrypy.org/ticket/581.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change in domain? Cherrypy.org got lost a few years ago.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops! fixed.

# It's also good to let them all shut down before allowing
# the main thread to call atexit handlers.
# See https://github.com/cherrypy/cherrypy/issues/751.
# See http://www.cherrypy.org/ticket/751.
self.bus.log('Waiting for child threads to terminate...')
curthread = threading.currentThread()
for t in threading.enumerate():
if t == threading.current_thread() or not t.is_alive():
if t is curthread:
continue

if not is_alive(t):
continue

# Note that any dummy (external) threads are always daemonic.
Expand Down
Loading