Skip to content

Commit 0fa2c8b

Browse files
committed
SSCursor: Fix connection closed check
Since the connection closes itself on an `asyncio.CancelledError`, it cannot be used afterwards. `SSCursor.close` attempts to clear some unfinished state first before closing using `Connection._finish_unbuffered_query`, but that call fails if the connection has been closed already and SSCursor itself does not properly check that.
1 parent 83aa96e commit 0fa2c8b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

aiomysql/cursors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,8 @@ class SSCursor(Cursor):
598598

599599
async def close(self):
600600
conn = self._connection
601-
if conn is None:
601+
if conn is None or conn.closed:
602+
self._connection = None
602603
return
603604

604605
if self._result is not None and self._result is conn._result:

0 commit comments

Comments
 (0)