From: Ben Darnell Date: Sat, 18 Apr 2015 15:57:22 +0000 (-0400) Subject: Add **kwargs to IOLoop initializers. X-Git-Tag: v4.2.0b1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=838e1cf0759f071d6f1bef64328edff99f7ce1ea;p=thirdparty%2Ftornado.git Add **kwargs to IOLoop initializers. This makes them compatible with the new make_current argument. Add additional delay in test_streaming_until_close_future for compatibility with AsyncIOLoop. --- diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 4a37a61cb..67e33b521 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -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: diff --git a/tornado/platform/asyncio.py b/tornado/platform/asyncio.py index cf1bf7a44..8f3dbff64 100644 --- a/tornado/platform/asyncio.py +++ b/tornado/platform/asyncio.py @@ -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): diff --git a/tornado/platform/twisted.py b/tornado/platform/twisted.py index 86380ba13..7b3c8ca5e 100644 --- a/tornado/platform/twisted.py +++ b/tornado/platform/twisted.py @@ -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 diff --git a/tornado/test/iostream_test.py b/tornado/test/iostream_test.py index 21b49c53f..45df6b50a 100644 --- a/tornado/test/iostream_test.py +++ b/tornado/test/iostream_test.py @@ -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() diff --git a/tornado/test/twisted_test.py b/tornado/test/twisted_test.py index cc445247c..8ace993d3 100644 --- a/tornado/test/twisted_test.py +++ b/tornado/test/twisted_test.py @@ -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):