gh-90467: StreamReaderProtocol - add strong reference to created task (GH-96323) (#96344)

(cherry picked from commit e860e521ec)

Co-authored-by: Kirill <iam@python273.pw>

Co-authored-by: Kirill <iam@python273.pw>
This commit is contained in:
Miss Islington (bot) 2022-08-30 03:59:32 -07:00 committed by GitHub
parent 16d8948c31
commit 126ec34558
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -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
@ -248,7 +249,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):
@ -266,6 +267,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):