Uh oh!
There was an error while loading. Please reload this page.
Use native coroutines instead of tornado coroutines - #632
Conversation
4c9ae9c to
3604092Comparedb887a1 to
1e7272bCompare
minrk
left a comment
There was a problem hiding this comment.
Makes sense. One minor suggestion that we preserve the maybe_future functionality to allow non-async methods, since most are in fact not async. That's probably the biggest breaking change here.
Since asyncio doesn't have its own maybe_future we can be more simplistic and just use:
result=maybe_async_api()
ifinspect.isawaitable(result):
result=awaitresultThe main difference this has is that concurrent.futures.Future is not awaitable. Everything tornado returns is, though (>=5.0, at lest). I think that's okay, though.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
11f8217 to
971383dCompareSylvainCorlay
commented
Apr 14, 2021
I could fix the in-process kernel tests. |
Uh oh!
There was an error while loading. Please reload this page.
SylvainCorlay
commented
Apr 14, 2021
Also, should I remove other uses of tornado in the code base in this PR? |
There was a problem hiding this comment.
should I remove other uses of tornado in the code base in this PR?
I think it's sensible to do it in stages, since this is a concrete discrete change.
It looks like the main thing left is our use of queues. However, asyncio's queue is not threadsafe, unlike tornado's, and the whole point of our use of the queues is inter-thread communication. So I think it makes sense to deal with that in its own PR, and keep this one to just Edit: tornado's queues are also not threadsafe. They are only called via async def.add_callback. But I can imagine there being subtle threadsafety issues, since we do use them across threads.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
971383d to
93a61cdCompareCarreau
commented
Apr 15, 2021
That looks great; with this, capturing of IO and some of the cleanup that has been done recently it would make a compelling release. We may even use the occasion to drop a couple deprecated things. |
SylvainCorlay
commented
Apr 16, 2021
👍 And debugger support! |
a2bfc64 to
e6ff9ffCompareSylvainCorlay
commented
Apr 21, 2021
Tornado queues are not thread safe, but it does not mean you can't use them with threads. It only means you can't use their APIs from a different thread where the ioloop runs - except for add_callback which is documented as being threadsafe. |
minrk
left a comment
There was a problem hiding this comment.
👍 in general. I'd only add that I think we shouldn't deprecate synchronous handlers, so I think we should skip the deprecation message, and shouldn't convert existing do_ methods and message handlers to async if they aren't already. There isn't really a benefit to that that I can see, and it does have a (tiny) performance cost.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
fb46301 to
583dc40Compareblink1073
commented
Apr 24, 2021
Kicking CI |
7b01b09 to
4965355Compareminrk
commented
Apr 24, 2021
Nice! |
SylvainCorlay
commented
Apr 24, 2021
Many thanks to @minrk for the careful review. |
blink1073
commented
Apr 24, 2021
Wow, good work y'all. 🎉 |
SylvainCorlay
commented
May 19, 2021
Yep, will be in 6.0. |

contextvarsdon't persist across cells in notebook ipython#11565 because tornado's wrapping of asyncio is a bit aggressive with creating Task objects which causes them to have a differentcontextvars.Context.cc @afshin@minrk@Carreau.
Note: tests are passing except for the in-process kernel tests, for which we will need to make more functions async.