Skip to content

Commit 087ac01

Browse files
committed
Make sure timeout callbacks always get cleaned up
Under certain circumstances the `TimerHandle` used for query timeouts does not get cleaned up in a timely fashion resulting in a temporary (`timeout` seconds) memory leak. Fixes: #830
1 parent 383c711 commit 087ac01

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

asyncpg/protocol/protocol.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,12 @@ cdef class BaseProtocol(CoreProtocol):
647647
self.waiter.set_exception(asyncio.TimeoutError())
648648

649649
def _on_waiter_completed(self, fut):
650+
if self.timeout_handle:
651+
self.timeout_handle.cancel()
652+
self.timeout_handle = None
650653
if fut is not self.waiter or self.cancel_waiter is not None:
651654
return
652655
if fut.cancelled():
653-
if self.timeout_handle:
654-
self.timeout_handle.cancel()
655-
self.timeout_handle = None
656656
self._request_cancel()
657657

658658
def _create_future_fallback(self):

0 commit comments

Comments
 (0)