]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add **kwargs to IOLoop initializers.
authorBen Darnell <ben@bendarnell.com>
Sat, 18 Apr 2015 15:57:22 +0000 (11:57 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 18 Apr 2015 15:57:22 +0000 (11:57 -0400)
This makes them compatible with the new make_current argument.

Add additional delay in test_streaming_until_close_future
for compatibility with AsyncIOLoop.

tornado/ioloop.py
tornado/platform/asyncio.py
tornado/platform/twisted.py
tornado/test/iostream_test.py
tornado/test/twisted_test.py

index 4a37a61cb674ba074f1a378be703e5d5c761149d..67e33b521f41c12e8b14a38f54d1961245cad487 100644 (file)
@@ -766,8 +766,10 @@ class PollIOLoop(IOLoop):
                     # IOLoop is just started once at the beginning.
                     signal.set_wakeup_fd(old_wakeup_fd)
                     old_wakeup_fd = None
-            except ValueError:  # non-main thread
-                pass
+            except ValueError:
+                # Non-main thread, or the previous value of wakeup_fd
+                # is no longer valid.
+                old_wakeup_fd = None
 
         try:
             while True:
index cf1bf7a4480549ba954891111979592f9006b668..8f3dbff640008bf0871b8c6e6462fe14dd08740a 100644 (file)
@@ -31,7 +31,8 @@ except ImportError as e:
 
 
 class BaseAsyncIOLoop(IOLoop):
-    def initialize(self, asyncio_loop, close_loop=False):
+    def initialize(self, asyncio_loop, close_loop=False, **kwargs):
+        super(BaseAsyncIOLoop, self).initialize(**kwargs)
         self.asyncio_loop = asyncio_loop
         self.close_loop = close_loop
         self.asyncio_loop.call_soon(self.make_current)
@@ -132,15 +133,15 @@ class BaseAsyncIOLoop(IOLoop):
 
 
 class AsyncIOMainLoop(BaseAsyncIOLoop):
-    def initialize(self):
+    def initialize(self, **kwargs):
         super(AsyncIOMainLoop, self).initialize(asyncio.get_event_loop(),
-                                                close_loop=False)
+                                                close_loop=False, **kwargs)
 
 
 class AsyncIOLoop(BaseAsyncIOLoop):
-    def initialize(self):
+    def initialize(self, **kwargs):
         super(AsyncIOLoop, self).initialize(asyncio.new_event_loop(),
-                                            close_loop=True)
+                                            close_loop=True, **kwargs)
 
 
 def to_tornado_future(asyncio_future):
index 86380ba1306b6ed25eccabb563ebc6b784cb6820..7b3c8ca5e39f26ae954222bbfb398c58b1a864a3 100644 (file)
@@ -416,7 +416,8 @@ class TwistedIOLoop(tornado.ioloop.IOLoop):
     because the ``SIGCHLD`` handlers used by Tornado and Twisted conflict
     with each other.
     """
-    def initialize(self, reactor=None):
+    def initialize(self, reactor=None, **kwargs):
+        super(TwistedIOLoop, self).initialize(**kwargs)
         if reactor is None:
             import twisted.internet.reactor
             reactor = twisted.internet.reactor
index 21b49c53fc9a46774d10dea0a9fdf971da8193dc..45df6b50a72cd6a8312e02bf52b6c46f5ed4c9c8 100644 (file)
@@ -340,7 +340,7 @@ class TestIOStreamMixin(object):
             @gen.coroutine
             def server_task():
                 yield server.write(b"1234")
-                yield gen.moment
+                yield gen.sleep(0.01)
                 yield server.write(b"5678")
                 server.close()
 
index cc445247cc592ed2e9720cde6cc92c782ec69745..8ace993d3937cd813be22dacad13ece21c524962 100644 (file)
@@ -659,13 +659,13 @@ if have_twisted:
         correctly.  In some tests another TornadoReactor is layered on top
         of the whole stack.
         """
-        def initialize(self):
+        def initialize(self, **kwargs):
             # When configured to use LayeredTwistedIOLoop we can't easily
             # get the next-best IOLoop implementation, so use the lowest common
             # denominator.
             self.real_io_loop = SelectIOLoop()
             reactor = TornadoReactor(io_loop=self.real_io_loop)
-            super(LayeredTwistedIOLoop, self).initialize(reactor=reactor)
+            super(LayeredTwistedIOLoop, self).initialize(reactor=reactor, **kwargs)
             self.add_callback(self.make_current)
 
         def close(self, all_fds=False):