From 59dd8d3bf8c9927ea33999cc2622c50d21c89752 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 7 May 2017 13:39:46 -0700 Subject: [PATCH] control: print remaining threads on forced shutdowns as well --- coremods/control.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/coremods/control.py b/coremods/control.py index 10f4f49..694930c 100644 --- a/coremods/control.py +++ b/coremods/control.py @@ -19,10 +19,14 @@ def remove_network(ircobj): ircobj.disconnect() del world.networkobjects[ircobj.name] +def _print_remaining_threads(): + log.debug('_shutdown(): Remaining threads: %s', ['%s/%s' % (t.name, t.ident) for t in threading.enumerate()]) + def _shutdown(irc=None): """Shuts down the Pylink daemon.""" global tried_shutdown if tried_shutdown: # We froze on shutdown last time, so immediately abort. + _print_remaining_threads() raise KeyboardInterrupt("Forcing shutdown.") tried_shutdown = True @@ -52,7 +56,7 @@ def _shutdown(irc=None): log.info("Waiting for remaining threads to stop; this may take a few seconds. If PyLink freezes " "at this stage, press Ctrl-C to force a shutdown.") - log.debug('_shutdown(): Remaining threads: %s', ['%s/%s' % (t.name, t.ident) for t in threading.enumerate()]) + _print_remaining_threads() # Done.