Permalink
Browse files

Fixed shutdown sequence in twisted reactor

  • Loading branch information...
1 parent 303e963 commit 53738a9c1db954496c57671eb1489d57d55c4727 @stiletto stiletto committed Jul 30, 2012
Showing with 2 additions and 3 deletions.
  1. +2 −3 tornado/platform/twisted.py
@@ -127,6 +127,7 @@ def __init__(self, io_loop=None):
self._fds = {} # a map of fd to a (reader, writer) tuple
self._delayedCalls = {}
PosixReactorBase.__init__(self)
+ self.addSystemEventTrigger('during', 'shutdown', self.crash)
# IOLoop.start() bypasses some of the reactor initialization.
# Fire off the necessary events if they weren't already triggered
@@ -280,7 +281,7 @@ def getWriters(self):
# IOLoop.start() instead of Reactor.run().
def stop(self):
PosixReactorBase.stop(self)
- self._io_loop.stop()
+ self.fireSystemEvent("shutdown")
def crash(self):
PosixReactorBase.crash(self)
@@ -291,8 +292,6 @@ def doIteration(self, delay):
def mainLoop(self):
self._io_loop.start()
- if self._stopped:
- self.fireSystemEvent("shutdown")
TornadoReactor = implementer(IReactorTime, IReactorFDSet)(TornadoReactor)

0 comments on commit 53738a9

Please sign in to comment.