Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSCursor: Fix connection closed check #991

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 9 additions & 0 deletions tests/test_sscursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ async def test_ssursor(connection):
await cursor.close()


@pytest.mark.run_loop
async def test_ssursor_conn_closed(connection):
conn = connection
cursor = await conn.cursor(SSCursor)

conn.close()
await cursor.close()


@pytest.mark.run_loop
async def test_sscursor_fetchall(connection):
conn = connection
Expand Down
Loading