-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Deprecate asyncio policy system #127949
Comments
asyncio.new_event_loop could just be deprecated in favour of asyncio.EventLoop |
I support the deprecation in general, details are the subject for future discussion. |
how about in 2 years (2 Python releases so 3.16 or 3.27) we swap the default loop_factory for |
FTR, With the current plan all of this would be deprecated at the same time so there won't be any issue like that. Footnotes |
First step towards deprecating the asyncio policy system. This deprecates `asyncio.set_event_loop_policy` and will be removed in Python 3.16.
This deprecates `asyncio.get_event_loop_policy` and will be removed in Python 3.16.
I'm now getting dozens of Details
And is the What's New entry to follow? Tip: add it to |
IIRC, Kumar said that he will defer docs and what's new when all the work is completed so to avoid many NEWS entries. For the tests, I think we forgot to suppress those that were not explicitly |
👍
Actually, I just made sure I was on latest Details
|
I tracked these down using tracemalloc #128172 |
@hugovk it would be good to configure warnings as errors in the tests, and collect unraisable exceptions like how pytest does it |
Would you like to open a new issue about it? Perhaps under https://github.com/python/core-workflow? |
I used to run Hmm,
|
Deprecate `asyncio.set_event_loop` to be removed in Python 3.16.
I've opened a discussion here: https://discuss.python.org/t/its-too-easy-to-introduce-noise-in-cpythons-test-suite-output-resourcewarnings-and-deprecationwarnings/75234 because that's what the core-workflow github issue template suggested |
Completed as all the deprecations and docs are added. |
Please could you also add the deprecation in this file? |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Done #128290 |
asyncio's policy system deprecation
asyncio's policy system1 has been a source of confusion and problems in asyncio for a very long time. The policies no longer serve a real purpose. Loops are always per thread, there is no need to have a "current loop" when no loop is currently running. This issue discusses the changes to deprecate it in Python 3.14 and schedule its removal in 3.16 or later.
The usual user applications would use the runner APIs (see flowchart) while those who want more control like Jupyter project can create an event loop and manage it themselves, the difference would be that instead of them first getting the policy then event loop then can directly create it like
rather than currently
See these discussions for more background:
Functions and classes to be deprecated and later removed
asyncio.get_event_loop_policy
asyncio.set_event_loop_policy
asyncio.AbstractEventLoopPolicy
asyncio.DefaultEventLoopPolicy
asyncio.WindowsSelectorEventLoopPolicy
asyncio.WindowsProactorEventLoopPolicy
asyncio.set_event_loop
Functions to be modified
asyncio.get_event_loop
- In 3.16 or later this will become an alias toget_running_loop
.asyncio.new_event_loop
- In 3.16 or later this will ignore custom policies and will be an alias toasyncio.EventLoop
asyncio.run
&asyncio.Runner
- In 3.16 or later this will be modified to not use policy system as that will be gone and rely solely on loop_factory.The Grand Plan
set_event_loop
->_set_event_loop
andset_event_loop
will emit the warning then call_set_event_loop
as its underlying implementation. This way internally asyncio can still call these functions until they are removed without need of many ignore warnings and the tests too can easily be adapted.The Future
Linked PRs
asyncio.set_event_loop_policy
#128024asyncio.get_event_loop_policy
#128053asyncio.set_event_loop
#128218Footnotes
https://docs.python.org/3.14/library/asyncio-policy.html ↩
The text was updated successfully, but these errors were encountered: