8000 Fix SSCursor raising query timeout error on wrong query · PyMySQL/PyMySQL@852eb5c · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 852eb5c

Browse files
committed
Fix SSCursor raising query timeout error on wrong query
1 parent dfe1ea2 commit 852eb5c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Release date: TBD
77
* Dropped support of end of life MySQL version 5.6
88
* Dropped support of end of life MariaDB versions below 10.3
99
* Dropped support of end of life Python version 3.6
10+
* Fixed SSCursor raising OperationalError for query timeouts on wrong statement #1032
1011

1112

1213
## v1.0.2

pymysql/connections.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,20 @@ def _finish_unbuffered_query(self):
12621262
# in fact, no way to stop MySQL from sending all the data after
12631263
# executing a query, so we just spin, and wait for an EOF packet.
12641264
while self.unbuffered_active:
1265-
packet = self.connection._read_packet()
1265+
try:
1266+
packet = self.connection._read_packet()
1267+
except err.OperationalError as e:
1268+
if e.args[0] in (
1269+
ER.QUERY_TIMEOUT,
1270+
ER.STATEMENT_TIMEOUT,
1271+
):
1272+
# if the query timed out we can simply ignore this error
1273+
self.unbuffered_active = False
1274+
self.connection = None
1275+
return
1276+
1277+
raise
1278+
12661279
if self._check_packet_is_eof(packet):
12671280
self.unbuffered_active = False
12681281
self.connection = None # release reference to kill cyclic reference.

0 commit comments

Comments
 (0)
0