From: Ben Darnell Date: Thu, 30 Jul 2015 03:02:42 +0000 (-0400) Subject: Correctly clear IOLoop.current() after TwistedIOLoop exits. X-Git-Tag: v4.3.0b1~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f697b4903722308c710c4c5d2060238db50f968;p=thirdparty%2Ftornado.git Correctly clear IOLoop.current() after TwistedIOLoop exits. --- diff --git a/tornado/platform/twisted.py b/tornado/platform/twisted.py index 7b3c8ca5e..0bb8d54fe 100644 --- a/tornado/platform/twisted.py +++ b/tornado/platform/twisted.py @@ -477,8 +477,15 @@ class TwistedIOLoop(tornado.ioloop.IOLoop): del self.fds[fd] def start(self): - self._setup_logging() - self.reactor.run() + old_current = IOLoop.current(instance=False) + try: + self._setup_logging() + self.reactor.run() + finally: + if old_current is None: + IOLoop.clear_current() + else: + old_current.make_current() def stop(self): self.reactor.crash()