Skip to content

Commit

Permalink
SSCursor: Fix connection closed check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
FichteFoll committed Sep 9, 2024
1 parent 83aa96e commit 0fa2c8b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aiomysql/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ class SSCursor(Cursor):

async def close(self):
conn = self._connection
if conn is None:
if conn is None or conn.closed:
self._connection = None
return

if self._result is not None and self._result is conn._result:
Expand Down

0 comments on commit 0fa2c8b

Please sign in to comment.