All Heartbeat futures should have the same timeout

This commit is contained in:
Alan Boudreault
2017-06-09 15:41:13 -04:00
parent 8e67b91ca9
commit e31394692d
2 changed files with 7 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ Bug Fixes
--------- ---------
* is_idempotent flag is not propagated from PreparedStatement to BoundStatement (PYTHON-736) * is_idempotent flag is not propagated from PreparedStatement to BoundStatement (PYTHON-736)
* Fix asyncore hang on exit (PYTHON-767) * Fix asyncore hang on exit (PYTHON-767)
* Driver takes several minutes to remove a bad host from session (PYTHON-762)
Other Other
----- -----

View File

@@ -990,11 +990,14 @@ class ConnectionHeartbeat(Thread):
owner.return_connection(connection) owner.return_connection(connection)
self._raise_if_stopped() self._raise_if_stopped()
# Wait max `self._interval` seconds for all HeartbeatFutures to complete
timeout = self._interval
start_time = time.time()
for f in futures: for f in futures:
self._raise_if_stopped() self._raise_if_stopped()
connection = f.connection connection = f.connection
try: try:
f.wait(self._interval) f.wait(timeout)
# TODO: move this, along with connection locks in pool, down into Connection # TODO: move this, along with connection locks in pool, down into Connection
with connection.lock: with connection.lock:
connection.in_flight -= 1 connection.in_flight -= 1
@@ -1004,6 +1007,8 @@ class ConnectionHeartbeat(Thread):
id(connection), connection.host) id(connection), connection.host)
failed_connections.append((f.connection, f.owner, e)) failed_connections.append((f.connection, f.owner, e))
timeout = self._interval - (time.time() - start_time)
for connection, owner, exc in failed_connections: for connection, owner, exc in failed_connections:
self._raise_if_stopped() self._raise_if_stopped()
connection.defunct(exc) connection.defunct(exc)