]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Correctly clear IOLoop.current() after TwistedIOLoop exits.
authorBen Darnell <ben@bendarnell.com>
Thu, 30 Jul 2015 03:02:42 +0000 (23:02 -0400)
committerBen Darnell <ben@bendarnell.com>
Thu, 30 Jul 2015 03:02:42 +0000 (23:02 -0400)
tornado/platform/twisted.py

index 7b3c8ca5e39f26ae954222bbfb398c58b1a864a3..0bb8d54fe9863425cd45a127658e3e5c2f63fb13 100644 (file)
@@ -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()