diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-09-08 15:39:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-08 15:39:20 (GMT) |
commit | 280130f035ff9eb28b3bd0e842764c7f935611fc (patch) | |
tree | 3919ad4f0018d798cde148443b4990f3a17d2701 | |
parent | 19b94bc136b188d3da5ab8d02b93eb55a48bc641 (diff) | |
download | cpython-280130f035ff9eb28b3bd0e842764c7f935611fc.zip cpython-280130f035ff9eb28b3bd0e842764c7f935611fc.tar.gz cpython-280130f035ff9eb28b3bd0e842764c7f935611fc.tar.bz2 |
gh-90467: StreamReaderProtocol - add strong reference to created task (GH-96323)
(cherry picked from commit e860e521ec0d84e175269aeb15cf24bd6053ad17)
Co-authored-by: Kirill <iam@python273.pw>
-rw-r--r-- | Lib/asyncio/streams.py | 4 | ||||
-rw-r--r-- | Misc/ACKS | 2 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-08-27-14-38-49.gh-issue-90467.VOOB0p.rst | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index 080d8a6..9c06cde 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -206,6 +206,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): self._strong_reader = stream_reader self._reject_connection = False self._stream_writer = None + self._task = None self._transport = None self._client_connected_cb = client_connected_cb self._over_ssl = False @@ -241,7 +242,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): res = self._client_connected_cb(reader, self._stream_writer) if coroutines.iscoroutine(res): - self._loop.create_task(res) + self._task = self._loop.create_task(res) self._strong_reader = None def connection_lost(self, exc): @@ -259,6 +260,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): super().connection_lost(exc) self._stream_reader_wr = None self._stream_writer = None + self._task = None self._transport = None def data_received(self, data): @@ -1428,6 +1428,7 @@ Ram Rachum Jeffrey Rackauckas Jérôme Radix Burton Radons +Kirill (python273) R. Abhilash Raj Shorya Raj Dhushyanth Ramasamy @@ -1966,6 +1967,7 @@ Gordon Worley Darren Worrall Thomas Wouters Daniel Wozniak +Simon Wrede Marcin Niemira Wei Wu Heiko Wundram diff --git a/Misc/NEWS.d/next/Library/2022-08-27-14-38-49.gh-issue-90467.VOOB0p.rst b/Misc/NEWS.d/next/Library/2022-08-27-14-38-49.gh-issue-90467.VOOB0p.rst new file mode 100644 index 0000000..282c0e7 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-08-27-14-38-49.gh-issue-90467.VOOB0p.rst @@ -0,0 +1,2 @@ +Fix :class:`asyncio.streams.StreamReaderProtocol` to keep a strong reference +to the created task, so that it's not garbage collected |