10000 Fix SSCursor raising query timeout error on wrong query on MySQL DB (… · aio-libs/aiomysql@1e474e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1e474 10000 e6

Browse files
authored
Fix SSCursor raising query timeout error on wrong query on MySQL DB (#761)
ports PyMySQL/PyMySQL@dd0f854 from PyMySQL/PyMySQL#1035 fixes #428
1 parent ef42007 commit 1e474e6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ To be included in 1.0.0 (unreleased)
2525
* Add rsa extras_require depending on PyMySQL[rsa] #557
2626
* Migrate to PEP 517 build system #746
2727
* Self-reported `__version__` now returns version generated by `setuptools-scm` during build, otherwise `'unknown'` #748
28+
* Fix SSCursor raising query timeout error on wrong query #428
2829

2930

3031
0.0.22 (2021-11-14)

aiomysql/connection.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,22 @@ async def _finish_unbuffered_query(self):
12471247
# in fact, no way to stop MySQL from sending all the data after
12481248
# executing a query, so we just spin, and wait for an EOF packet.
12491249
while self.unbuffered_active:
1250-
packet = await self.connection._read_packet()
1250+
try:
1251+
packet = await self.connection._read_packet()
1252+
except OperationalError as e:
1253+
# TODO: replace these numbers with constants when available
1254+
# TODO: in a new PyMySQL release
1255+
if e.args[0] in (
1256+
3024, # ER.QUERY_TIMEOUT
1257+
1969, # ER.STATEMENT_TIMEOUT
1258+
):
1259+
# if the query timed out we can simply ignore this error
1260+
self.unbuffered_active = False
1261+
self.connection = None
1262+
return
1263+
1264+
raise
1265+
12511266
if self._check_packet_is_eof(packet):
12521267
self.unbuffered_active = False
12531268
# release reference to kill cyclic reference.

0 commit comments

Comments
 (0)
0