diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-12-06 17:42:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-06 17:42:12 (GMT) |
commit | fd38a2f0ec03b4eec5e3cfd41241d198b1ee555a (patch) | |
tree | f5019c34b08ec4dbfcbcd95edbde05553d283481 /Lib/asyncio/streams.py | |
parent | b72014c783e5698beb18ee1249597e510b8bcb5a (diff) | |
download | cpython-fd38a2f0ec03b4eec5e3cfd41241d198b1ee555a.zip cpython-fd38a2f0ec03b4eec5e3cfd41241d198b1ee555a.tar.gz cpython-fd38a2f0ec03b4eec5e3cfd41241d198b1ee555a.tar.bz2 |
gh-93453: No longer create an event loop in get_event_loop() (#98440)
asyncio.get_event_loop() now always return either running event loop or
the result of get_event_loop_policy().get_event_loop() call. The latter
should now raise an RuntimeError if no current event loop was set
instead of creating and setting a new event loop.
It affects also a number of asyncio functions and constructors which
call get_event_loop() implicitly: ensure_future(), shield(), gather(),
etc.
DeprecationWarning is no longer emitted if there is no running event loop but
the current event loop was set.
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r-- | Lib/asyncio/streams.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index c4d837a..3bd9904 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -125,7 +125,7 @@ class FlowControlMixin(protocols.Protocol): def __init__(self, loop=None): if loop is None: - self._loop = events._get_event_loop(stacklevel=4) + self._loop = events.get_event_loop() else: self._loop = loop self._paused = False @@ -404,7 +404,7 @@ class StreamReader: self._limit = limit if loop is None: - self._loop = events._get_event_loop() + self._loop = events.get_event_loop() else: self._loop = loop self._buffer = bytearray() |