Created
November 6, 2017 16:59
-
-
Save pitrou/d0ed381729ef9045491263774311e9f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
from tornado import gen | |
from tornado.concurrent import Future | |
from tornado.ioloop import IOLoop | |
fut = Future() | |
#print("in main:", fut, id(getattr(fut, '_loop', None))) | |
@gen.coroutine | |
def f(): | |
loop = IOLoop.current() | |
loop.call_later(1, fut.set_result, None) | |
#print("in thread:", id(loop.asyncio_loop), id(getattr(fut, '_loop', None))) | |
assert (yield fut) is None | |
t = threading.Thread(target=IOLoop().run_sync, args=(f,)) | |
t.start() | |
t.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment