mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
gh-100160: Restore and deprecate implicit creation of an event loop (GH-100410)
Partially revert changes made in GH-93453. asyncio.DefaultEventLoopPolicy.get_event_loop() now emits a DeprecationWarning and creates and sets a new event loop instead of raising a RuntimeError if there is no current event loop set. Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
This commit is contained in:
parent
468c3bf798
commit
e5bd5ad70d
8 changed files with 77 additions and 41 deletions
|
@ -48,7 +48,7 @@ an event loop:
|
|||
running event loop.
|
||||
|
||||
If there is no running event loop set, the function will return
|
||||
the result of calling ``get_event_loop_policy().get_event_loop()``.
|
||||
the result of the ``get_event_loop_policy().get_event_loop()`` call.
|
||||
|
||||
Because this function has rather complex behavior (especially
|
||||
when custom event loop policies are in use), using the
|
||||
|
@ -59,11 +59,9 @@ an event loop:
|
|||
instead of using these lower level functions to manually create and close an
|
||||
event loop.
|
||||
|
||||
.. note::
|
||||
In Python versions 3.10.0--3.10.8 and 3.11.0 this function
|
||||
(and other functions which used it implicitly) emitted a
|
||||
:exc:`DeprecationWarning` if there was no running event loop, even if
|
||||
the current loop was set.
|
||||
.. deprecated:: 3.12
|
||||
Deprecation warning is emitted if there is no current event loop.
|
||||
In some future Python release this will become an error.
|
||||
|
||||
.. function:: set_event_loop(loop)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue