You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
asyncio will be running by default with tornado 5 #11030
When tornado 5 is released, which is scheduled to be this month, the tornado ioloop will run on asyncio by default. For the most part, this is nice because asyncio will always be running (#9166), but it's also tricky because simple cells like this that assume asyncio isn't running will stop working:
loop=asyncio.get_event_loop()
# will fail because loop is already running:loop.run_until_complete(asyncio.sleep(1))
Without something like #10390, there won't be an easy way that I can see for users to run asyncio code in IPython, other than putting them in a background thread where they can run it in an eventloop:
The code suggested by @fortuna didn't work for me (I don't know why, it was a more complicated situation than in the examples shown here, probably I just made a mistake), but [UPDATE: I indeed made a mistake, the code provided by @fortuna works fine] I came up with a slightly more concise variant of @minrk's original suggestion:
Activity
Degrade tornado to 4.5.3 to avoid ipython/ipython#11030
minrk commentedon Mar 28, 2018
Here's a quick hack to provide an
%%asynciomagic running async functions in the aio_thread:fortuna commentedon Mar 31, 2018
It would be great if this was made easier.
I was able to at least find a simpler workaround:
fortuna commentedon Mar 31, 2018
Here is an alternative to above.
One time setup:
Whenever you need async:
mgeier commentedon Apr 6, 2018
The code suggested by @fortuna didn't work for me (I don't know why, it was a more complicated situation than in the examples shown here, probably I just made a mistake), but[UPDATE: I indeed made a mistake, the code provided by @fortuna works fine] I came up with a slightly more concise variant of @minrk's original suggestion:I think this should be equivalent to the code at the top of this page, but I'm an
asynciobeginner, so I might be completely wrong.BTW, if somebody is using
asyncio.create_subprocess_exec(), I had to add this:Without it, I got:
Carreau commentedon Nov 1, 2018
We now have asyncio repl closing.
fm75 commentedon Nov 1, 2018
Excellent! Is this in a release?
Carreau commentedon Nov 1, 2018
Yes, see https://ipython.readthedocs.io/en/stable/whatsnew/version7.html#ipython-7-0-0
You can just await:
And it works.
fm75 commentedon Nov 1, 2018
Indeed! Awesome. Just testing in the-littlest-jupyterhub that I set up this week.
Thank you.