Skip to content

Commit 3465ec8

Browse files
committed
HearbeatFuture: Use correct timeout in error message
The timeout argument in `wait` tells how much we need to wait taking into consideration that we already waited for some other futures. This created confusing hearbeat messages, that could even show negative wait times.
1 parent f0f13ee commit 3465ec8

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

cassandra/connection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,15 +1821,15 @@ def __init__(self, connection, owner):
18211821
self._exception = Exception("Failed to send heartbeat because connection 'in_flight' exceeds threshold")
18221822
self._event.set()
18231823

1824-
def wait(self, timeout):
1824+
def wait(self, timeout, original_timeout):
18251825
self._event.wait(timeout)
18261826
if self._event.is_set():
18271827
if self._exception:
18281828
raise self._exception
18291829
else:
1830-
raise OperationTimedOut("Connection heartbeat timeout after %s seconds" % (timeout,),
1830+
raise OperationTimedOut("Connection heartbeat timeout after %s seconds" % (original_timeout,),
18311831
self.connection.endpoint,
1832-
timeout=timeout,
1832+
timeout=original_timeout,
18331833
in_flight=self.connection.in_flight)
18341834

18351835
def _options_callback(self, response):
@@ -1894,7 +1894,7 @@ def run(self):
18941894
self._raise_if_stopped()
18951895
connection = f.connection
18961896
try:
1897-
f.wait(timeout_left)
1897+
f.wait(timeout_left, self._timeout)
18981898
# TODO: move this, along with connection locks in pool, down into Connection
18991899
with connection.lock:
19001900
connection.in_flight -= 1

0 commit comments

Comments
 (0)