Skip to content

Commit 0a49130

Browse files
committed
Fix cancellation code to correctly ensure proper state of the waiter
1 parent f280a56 commit 0a49130

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

asyncpg/protocol/protocol.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ cdef class BaseProtocol(CoreProtocol):
503503
self.timeout_handle = None
504504

505505
if self.cancel_waiter is not None:
506-
if self.waiter is None or not self.waiter.cancelled():
507-
self.cancel_waiter.set_result(
506+
if self.waiter is not None and not self.waiter.done():
507+
self.cancel_waiter.set_exception(
508508
RuntimeError('invalid state after cancellation'))
509509
else:
510510
self.cancel_waiter.set_result(None)

0 commit comments

Comments
 (0)