mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-38529: Fix asyncio stream warning (GH-17474)
This commit is contained in:
parent
dec367261e
commit
7ddcd0caa4
3 changed files with 3 additions and 71 deletions
|
@ -214,8 +214,7 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
|
|||
def __init__(self, stream_reader, client_connected_cb=None, loop=None):
|
||||
super().__init__(loop=loop)
|
||||
if stream_reader is not None:
|
||||
self._stream_reader_wr = weakref.ref(stream_reader,
|
||||
self._on_reader_gc)
|
||||
self._stream_reader_wr = weakref.ref(stream_reader)
|
||||
self._source_traceback = stream_reader._source_traceback
|
||||
else:
|
||||
self._stream_reader_wr = None
|
||||
|
@ -231,22 +230,6 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
|
|||
self._over_ssl = False
|
||||
self._closed = self._loop.create_future()
|
||||
|
||||
def _on_reader_gc(self, wr):
|
||||
transport = self._transport
|
||||
if transport is not None:
|
||||
# connection_made was called
|
||||
context = {
|
||||
'message': ('An open stream object is being garbage '
|
||||
'collected; call "stream.close()" explicitly.')
|
||||
}
|
||||
if self._source_traceback:
|
||||
context['source_traceback'] = self._source_traceback
|
||||
self._loop.call_exception_handler(context)
|
||||
transport.abort()
|
||||
else:
|
||||
self._reject_connection = True
|
||||
self._stream_reader_wr = None
|
||||
|
||||
@property
|
||||
def _stream_reader(self):
|
||||
if self._stream_reader_wr is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue