mirror of
https://github.com/python/cpython.git
synced 2024-11-28 12:31:14 +08:00
gh-90467: StreamReaderProtocol - add strong reference to created task (#96323)
This commit is contained in:
parent
6fbd889d6e
commit
e860e521ec
@ -205,6 +205,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
|
||||
@ -247,7 +248,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):
|
||||
@ -265,6 +266,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):
|
||||
|
@ -1442,6 +1442,7 @@ Ram Rachum
|
||||
Jeffrey Rackauckas
|
||||
Jérôme Radix
|
||||
Burton Radons
|
||||
Kirill (python273) R.
|
||||
Abhilash Raj
|
||||
Shorya Raj
|
||||
Ajith Ramachandran
|
||||
@ -1987,6 +1988,7 @@ Gordon Worley
|
||||
Darren Worrall
|
||||
Thomas Wouters
|
||||
Daniel Wozniak
|
||||
Simon Wrede
|
||||
Marcin Niemira
|
||||
Wei Wu
|
||||
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…
Reference in New Issue
Block a user