Skip to content

Commit 9ee9331

Browse files
author
nick
committed
Initial fix for PYTHON-1044
1 parent 30a0e27 commit 9ee9331

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cassandra/cluster.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,11 +3722,14 @@ def _on_timeout(self, _attempts=0):
37223722
if self._connection is not None:
37233723
try:
37243724
self._connection._requests.pop(self._req_id)
3725-
# This prevents the race condition of the
3726-
# event loop thread just receiving the waited message
3727-
# If it arrives after this, it will be ignored
3725+
# PYTHON-1044
3726+
# This request might have been removed from the connection after the latter was defunct by heartbeat.
3727+
# We should still raise OperationTimedOut to reject the future so that the main event thread will not
3728+
# wait for it endlessly
37283729
except KeyError:
3729-
return
3730+
key = "Connection defunct by heartbeat"
3731+
errors = {key: "Client request timeout. See Session.execute[_async](timeout)"}
3732+
self._set_final_exception(OperationTimedOut(errors, self._current_host))
37303733

37313734
pool = self.session._pools.get(self._current_host)
37323735
if pool and not pool.is_shutdown:

0 commit comments

Comments
 (0)