Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion cassandra/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4117,7 +4117,8 @@ def wait_for_schema_agreement(self, connection=None, preloaded_results=None, wai
local_query = QueryMessage(query=maybe_add_timeout_to_query(self._SELECT_SCHEMA_LOCAL, self._metadata_request_timeout),
consistency_level=cl)
try:
timeout = min(self._timeout, total_timeout - elapsed)
remaining = total_timeout - elapsed
timeout = min(self._timeout, remaining) if self._timeout is not None else remaining
peers_result, local_result = connection.wait_for_responses(
peers_query, local_query, timeout=timeout)
except OperationTimedOut as timeout:
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_control_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,20 @@ def test_wait_for_schema_agreement_rpc_lookup(self):
assert not self.control_connection.wait_for_schema_agreement()
assert self.time.clock >= self.cluster.max_schema_agreement_wait


def test_wait_for_schema_agreement_none_timeout(self):
"""
When control_connection_timeout is None, wait_for_schema_agreement
should not raise a TypeError on the min() call.
"""
cc = ControlConnection(self.cluster, timeout=None,
schema_event_refresh_window=0,
topology_event_refresh_window=0,
status_event_refresh_window=0)
cc._connection = self.connection
cc._time = self.time
assert cc.wait_for_schema_agreement()

def test_refresh_nodes_and_tokens(self):
self.control_connection.refresh_node_list_and_token_map()
meta = self.cluster.metadata
Expand Down
Loading