Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix SSCursor raising query timeout error on wrong query
  • Loading branch information
Nothing4You committed Jul 14, 2022
commit 852eb5c69cbc732e55b29cb9eeb171e7fb5fa78b
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Release date: TBD
* Dropped support of end of life MySQL version 5.6
* Dropped support of end of life MariaDB versions below 10.3
* Dropped support of end of life Python version 3.6
* Fixed SSCursor raising OperationalError for query timeouts on wrong statement #1032


## v1.0.2
Expand Down
15 changes: 14 additions & 1 deletion pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,20 @@ def _finish_unbuffered_query(self):
# in fact, no way to stop MySQL from sending all the data after
# executing a query, so we just spin, and wait for an EOF packet.
while self.unbuffered_active:
packet = self.connection._read_packet()
try:
packet = self.connection._read_packet()
except err.OperationalError as e:
if e.args[0] in (
ER.QUERY_TIMEOUT,
ER.STATEMENT_TIMEOUT,
):
# if the query timed out we can simply ignore this error
self.unbuffered_active = False
self.connection = None
return

raise

if self._check_packet_is_eof(packet):
self.unbuffered_active = False
self.connection = None # release reference to kill cyclic reference.
Expand Down