-
-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use native coroutines instead of tornado coroutines #632
Conversation
4c9ae9c
to
3604092
Compare
db887a1
to
1e7272b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()
if inspect.isawaitable(result):
result = await result
The 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.
11f8217
to
971383d
Compare
I could fix the in-process kernel tests. |
Also, should I remove other uses of tornado in the code base in this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
971383d
to
93a61cd
Compare
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. |
👍 And debugger support! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
a2bfc64
to
e6ff9ff
Compare
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 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.
fb46301
to
583dc40
Compare
Kicking CI |
7b01b09
to
4965355
Compare
Nice! |
Many thanks to @minrk for the careful review. |
Wow, good work y'all. 🎉 |
Yep, will be in 6.0. |
contextvars
don'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.