-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Pattern for deprecated IOLoop constructor #3156
Comments
Thanks for the feedback and for testing the new beta. It's a bug that the behavior of the current code has changed - the only intentional change is to start emitting deprecation warnings (when those are enabled) in some places. I'll take a look and see why it's breaking. That's an interesting observation about AsyncIOLoop vs IOLoop. I forgot that class still exists with slightly different semantics from the default. It should be emitting a deprecation warning if make_current=True, but other than that I think we could consider supporting that pattern. Maybe we could even undeprecate the IOLoop constructor with make_current=False and give it the semantics of AsyncIOLoop. |
Thanks! That makes sense. Keeping everything working with the 3.10 deprecations is pretty tough, so I don't mind needing updates to do the 'make a loop, configure it, then start it' pattern. I'd just like to do whatever you think is the official way to do that. Certainly, "wrap it all in one big asyncio.run" is one option, but more of a pain to adapt to. |
btw, I was wrong about the above code working without |
After chasing my tail for longer than it should have taken, Sorry if you wasted time on this, too! |
Great. Looks like the |
The constructor is not completely deprecated; the make_current=False mode is still usable. Fixes tornadoweb#3156
The constructor is not completely deprecated; the make_current=False mode is still usable. Fixes tornadoweb#3156
The constructor is not completely deprecated; the make_current=False mode is still usable. Fixes tornadoweb#3156
I see in 6.2 beta that the IOLoop constructor is deprecated, and that migration docs are forthcoming. I wanted to report how we've been using one of the deprecated patterns as an example of something that might need migration.
We have a pattern of using tornado to handle some background IO in threads, that looks like:
This pattern of creating the loop and talking to it before it starts is super useful. But the code as-is has started failing with the 6.2 beta (I'm not sure if the breakage is intentional or not), and I see that calling
IOLoop()
constructor directly is deprecated, which I understand given its relationship to the deprecatedasyncio.get_event_loop()
.Now, I've found that the following code works, if I explicitly choose the
AsyncIOLoop
implementation:This makes sense to me, because AsyncIOLoop explicitly calls
asyncio.new_event_loop
and doesn't rely on any globals like get/set_event_loop. Is this a reasonable approach? Or is creating/accessing any tornado IOLoop while the asyncio loop is not running going to be unsupported, or at least discouraged?Explicitly creating / having a handle on the event loop is easy enough with asyncio, but if we can't get a handle on the tornado IOLoop object until asyncio is running in the background thread, that's going to be a pain.
The text was updated successfully, but these errors were encountered: