Joel Rivera  committed 54171dd

Bugfix of a potential deadlock if the main bus is stopped from a different
thread than the main thread, this is the case when is implemented as a
windows service.

Closing issue #1164
Closing issue #1101

  • Participants
  • Parent commits 85b6759

Comments (0)

Files changed (1)

File cherrypy/process/

         # See
         self.log("Waiting for child threads to terminate...")
         for t in threading.enumerate():
-            if t != threading.currentThread() and t.isAlive():
+            # Validate the we're not trying to join the MainThread
+            # that will cause a deadlock and the case exist when imlemented as a 
+            # windows service and in any other case that another thread
+            # executes cherrypy.engine.exit()
+            if t != threading.currentThread() and t.isAlive() \
+              and not isinstance(t, threading._MainThread):
                 # Note that any dummy (external) threads are always daemonic.
                 if hasattr(threading.Thread, "daemon"):
                     # Python 2.6+