mirror of
https://github.com/python/cpython.git
synced 2025-08-17 23:31:09 +00:00
gh-90467: StreamReaderProtocol - add strong reference to created task (GH-96323)
(cherry picked from commit e860e521ec
)
Co-authored-by: Kirill <iam@python273.pw>
This commit is contained in:
parent
19b94bc136
commit
280130f035
3 changed files with 7 additions and 1 deletions
|
@ -206,6 +206,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
|
||||||
self._strong_reader = stream_reader
|
self._strong_reader = stream_reader
|
||||||
self._reject_connection = False
|
self._reject_connection = False
|
||||||
self._stream_writer = None
|
self._stream_writer = None
|
||||||
|
self._task = None
|
||||||
self._transport = None
|
self._transport = None
|
||||||
self._client_connected_cb = client_connected_cb
|
self._client_connected_cb = client_connected_cb
|
||||||
self._over_ssl = False
|
self._over_ssl = False
|
||||||
|
@ -241,7 +242,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
|
||||||
res = self._client_connected_cb(reader,
|
res = self._client_connected_cb(reader,
|
||||||
self._stream_writer)
|
self._stream_writer)
|
||||||
if coroutines.iscoroutine(res):
|
if coroutines.iscoroutine(res):
|
||||||
self._loop.create_task(res)
|
self._task = self._loop.create_task(res)
|
||||||
self._strong_reader = None
|
self._strong_reader = None
|
||||||
|
|
||||||
def connection_lost(self, exc):
|
def connection_lost(self, exc):
|
||||||
|
@ -259,6 +260,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
|
||||||
super().connection_lost(exc)
|
super().connection_lost(exc)
|
||||||
self._stream_reader_wr = None
|
self._stream_reader_wr = None
|
||||||
self._stream_writer = None
|
self._stream_writer = None
|
||||||
|
self._task = None
|
||||||
self._transport = None
|
self._transport = None
|
||||||
|
|
||||||
def data_received(self, data):
|
def data_received(self, data):
|
||||||
|
|
|
@ -1428,6 +1428,7 @@ Ram Rachum
|
||||||
Jeffrey Rackauckas
|
Jeffrey Rackauckas
|
||||||
Jérôme Radix
|
Jérôme Radix
|
||||||
Burton Radons
|
Burton Radons
|
||||||
|
Kirill (python273) R.
|
||||||
Abhilash Raj
|
Abhilash Raj
|
||||||
Shorya Raj
|
Shorya Raj
|
||||||
Dhushyanth Ramasamy
|
Dhushyanth Ramasamy
|
||||||
|
@ -1966,6 +1967,7 @@ Gordon Worley
|
||||||
Darren Worrall
|
Darren Worrall
|
||||||
Thomas Wouters
|
Thomas Wouters
|
||||||
Daniel Wozniak
|
Daniel Wozniak
|
||||||
|
Simon Wrede
|
||||||
Marcin Niemira
|
Marcin Niemira
|
||||||
Wei Wu
|
Wei Wu
|
||||||
Heiko Wundram
|
Heiko Wundram
|
||||||
|
|
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue