From 75cbbd2e909c8eadccafbec2b571b9897b847ec7 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Fri, 6 Nov 2026 16:10:23 -0600 Subject: [PATCH 1/2] Demonstrate `RetryConfig` duplicate check accumulation --- tests/unit/test_base_client.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit/test_base_client.py b/tests/unit/test_base_client.py index 9bdd0a656..252480657 100644 --- a/tests/unit/test_base_client.py +++ b/tests/unit/test_base_client.py @@ -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 From 892b5d69123179767ce91ccfcbb6d7c3cf19116e Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Fri, 6 Nov 2026 16:19:37 -0600 Subject: [PATCH 2/2] Fix a bug that allowed duplicate `RetryConfig` checks to accumulate --- changelog.d/20261106_155825_kurtmckee.rst | 10 ++++++++++ src/globus_sdk/transport/retry.py | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20261106_155825_kurtmckee.rst diff --git a/changelog.d/20261106_155825_kurtmckee.rst b/changelog.d/20261106_155825_kurtmckee.rst new file mode 100644 index 000000000..a5a37542b --- /dev/null +++ b/changelog.d/20261106_155825_kurtmckee.rst @@ -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. diff --git a/src/globus_sdk/transport/retry.py b/src/globus_sdk/transport/retry.py index d1693dfb2..12014246b 100644 --- a/src/globus_sdk/transport/retry.py +++ b/src/globus_sdk/transport/retry.py @@ -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: