From 175360bbb13b87a068611f4a409451580aca6b70 Mon Sep 17 00:00:00 2001 From: Elvis Pranskevichus Date: Sat, 7 Aug 2021 14:00:14 -0700 Subject: [PATCH] Do not attempt to del transport in connection_lost if it has been already --- edgedb/protocol/asyncio_proto.pyx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/edgedb/protocol/asyncio_proto.pyx b/edgedb/protocol/asyncio_proto.pyx index c29fd5f8..2df4aa97 100644 --- a/edgedb/protocol/asyncio_proto.pyx +++ b/edgedb/protocol/asyncio_proto.pyx @@ -112,13 +112,14 @@ cdef class AsyncIOProtocol(protocol.SansIOProtocol): self.msg_waiter.set_exception(ConnectionResetError()) self.msg_waiter = None - # With asyncio sslproto on CPython 3.10 or lower, a normal exit - # (connection closed by peer) cannot set the transport._closed - # properly, leading to false ResourceWarning. Let's fix that by - # closing the transport again. - if not self.transport.is_closing(): - self.transport.close() - self.transport = None + if self.transport is not None: + # With asyncio sslproto on CPython 3.10 or lower, a normal exit + # (connection closed by peer) cannot set the transport._closed + # properly, leading to false ResourceWarning. Let's fix that by + # closing the transport again. + if not self.transport.is_closing(): + self.transport.close() + self.transport = None def pause_writing(self): pass