summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/streams.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-04-25 10:40:44 (GMT)
committerGitHub <noreply@github.com>2021-04-25 10:40:44 (GMT)
commit172c0f2752d8708b6dda7b42e6c5a3519420a4e8 (patch)
tree35a076c6baad7ca053a62b9f505af3762a867b79 /Lib/asyncio/streams.py
parentface87c94e67ad9c72b9a3724f112fd76c1002b9 (diff)
downloadcpython-172c0f2752d8708b6dda7b42e6c5a3519420a4e8.zip
cpython-172c0f2752d8708b6dda7b42e6c5a3519420a4e8.tar.gz
cpython-172c0f2752d8708b6dda7b42e6c5a3519420a4e8.tar.bz2
bpo-39529: Deprecate creating new event loop in asyncio.get_event_loop() (GH-23554)
asyncio.get_event_loop() emits now a deprecation warning when it creates a new event loop. In future releases it will became an alias of asyncio.get_running_loop().
Diffstat (limited to 'Lib/asyncio/streams.py')
-rw-r--r--Lib/asyncio/streams.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index 96a9f97..080d8a6 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()
+ self._loop = events._get_event_loop(stacklevel=4)
else:
self._loop = loop
self._paused = False
@@ -283,9 +283,13 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
def __del__(self):
# Prevent reports about unhandled exceptions.
# Better than self._closed._log_traceback = False hack
- closed = self._closed
- if closed.done() and not closed.cancelled():
- closed.exception()
+ try:
+ closed = self._closed
+ except AttributeError:
+ pass # failed constructor
+ else:
+ if closed.done() and not closed.cancelled():
+ closed.exception()
class StreamWriter:
@@ -381,7 +385,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()