Skip to content

Commit e63942d

Browse files
Copilotdkropachev
andcommitted
Use if success pattern instead of try/except per review
Replace try/except block with if success pattern to match original code style when using fail_on_error=False. This is consistent with how the code was structured before adding paging support. Addresses @dkropachev's feedback to use `if success:` as it was before. Co-authored-by: dkropachev <[email protected]>
1 parent a4a0155 commit e63942d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cassandra/cluster.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3923,15 +3923,16 @@ def _refresh_node_list_and_token_map(self, connection, preloaded_results=None,
39233923
query=maybe_add_timeout_to_query(self._SELECT_LOCAL_NO_TOKENS_RPC_ADDRESS, self._metadata_request_timeout),
39243924
consistency_level=ConsistencyLevel.ONE,
39253925
fetch_size=self._schema_meta_page_size)
3926-
try:
3927-
# Fetch all pages (system.local table always contains exactly one row, so this is effectively a no-op)
3928-
local_rpc_address_result = _fetch_remaining_pages(connection, local_rpc_address_query, self._timeout)
3926+
# Fetch all pages (system.local table always contains exactly one row, so this is effectively a no-op)
3927+
success, local_rpc_address_result = _fetch_remaining_pages(
3928+
connection, local_rpc_address_query, self._timeout, fail_on_error=False)
3929+
if success:
39293930
row = dict_factory(
39303931
local_rpc_address_result.column_names,
39313932
local_rpc_address_result.parsed_rows)
39323933
host.broadcast_rpc_address = _NodeInfo.get_broadcast_rpc_address(row[0])
39333934
host.broadcast_rpc_port = _NodeInfo.get_broadcast_rpc_port(row[0])
3934-
except Exception:
3935+
else:
39353936
host.broadcast_rpc_address = connection.endpoint.address
39363937
host.broadcast_rpc_port = connection.endpoint.port
39373938

0 commit comments

Comments
 (0)