Skip to content
Merged
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
10 changes: 10 additions & 0 deletions changelog.d/20261106_155825_kurtmckee.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Fixed
-----

- Fix a bug that allowed duplicate ``RetryConfig`` checks to accumulate. (:pr:`NUMBER`)

This bug could be triggered by instantiating ``RetryConfig`` once
and passing that instance to multiple SDK clients.

``RetryCheckCollection.register_check`` now ignores a check
which is already registered.
6 changes: 5 additions & 1 deletion src/globus_sdk/transport/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,13 @@ def register_check(self, func: RetryCheck) -> RetryCheck:
`check` should *not* perform any sleeps or delays.
Multiple checks should be chainable and callable in any order.

Registering a check which is already present is a no-op.
The check keeps the position of its first registration.

:param func: The function or other callable to register as a retry check
"""
self._data.append(func)
if func not in self._data:
self._data.append(func)
return func

def register_many_checks(self, funcs: t.Iterable[RetryCheck]) -> None:
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/test_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,31 @@ def test_client_context_manager_exit_calls_close(base_client_class):
with base_client_class():
client_close_method.assert_not_called()
client_close_method.assert_called_once()


def test_clients_sharing_a_retry_config_do_not_accumulate_retry_checks(
base_client_class,
):
"""
Verify RetryConfig doesn't accumulate duplicate checks.

This is a regression test.

Previously, instantiating a client with a shared RetryConfig
(for example, by using a module- or class-level RetryConfig instance)
would cause duplicate checks to be added to the retry config.
"""

# One RetryConfig passed to many clients must not accumulate checks
# every time a client is instantiated.
retry_config = globus_sdk.transport.RetryConfig()

base_client_class(retry_config=retry_config)
checks_after_first_client = list(retry_config.checks)
assert len(checks_after_first_client) # Guard against a vacuous test.

for _ in range(3):
base_client_class(retry_config=retry_config)

# A list, rather than a set, is used to verify check ordering as well.
assert list(retry_config.checks) == checks_after_first_client
Loading