asyncio: Break reference cycle in StreamReaderProtocol.connection_lost

This commit is contained in:
Yury Selivanov 2016-05-13 15:58:00 -04:00
parent 04eb87e4ef
commit 32dae3d50f
1 changed files with 7 additions and 4 deletions

View File

@ -242,11 +242,14 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
self._loop.create_task(res)
def connection_lost(self, exc):
if exc is None:
self._stream_reader.feed_eof()
else:
self._stream_reader.set_exception(exc)
if self._stream_reader is not None:
if exc is None:
self._stream_reader.feed_eof()
else:
self._stream_reader.set_exception(exc)
super().connection_lost(exc)
self._stream_reader = None
self._stream_writer = None
def data_received(self, data):
self._stream_reader.feed_data(data)