This makes them compatible with the new make_current argument.
Add additional delay in test_streaming_until_close_future
for compatibility with AsyncIOLoop.
# 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:
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)
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):
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
@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()
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):