Skip to content

Commit 59a4e06

Browse files
committed
fix: honor the retries option
SeamHttpClient assigned self.retries after calling niquests.Session.__init__, by which point the session had already mounted its adapters with the default max_retries. The retries option was therefore silently ignored: a caller passing Retry(total=5, status_forcelist=[503]) still got exactly one attempt. Pass retries through to niquests.Session so the mounted adapters are built with it. Seam and SeamMultiWorkspace default the option to None, which now falls back to DEFAULT_RETRIES rather than being dropped. Drops the xfail markers from the two retry tests that covered this. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011DzapiU8A9NMdyoTybL9xB
1 parent f38df32 commit 59a4e06

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

seam/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,18 @@ def __init__(
4747
retries: Optional[Retry] = DEFAULT_RETRIES,
4848
**kwargs
4949
):
50-
super().__init__(**kwargs)
50+
# niquests.Session mounts its adapters while initializing, so retries
51+
# must be passed through here. Assigning self.retries afterwards leaves
52+
# the mounted adapters on their default and the option has no effect.
53+
super().__init__(
54+
retries=DEFAULT_RETRIES if retries is None else retries, **kwargs
55+
)
5156

5257
self.base_url = base_url
5358

5459
headers = {**auth_headers, **kwargs.get("headers", {}), **SDK_HEADERS}
5560
self.headers.update(headers)
5661

57-
if retries:
58-
self.retries = retries
59-
6062
def request(self, method, url, *args, **kwargs):
6163
url = urljoin(self.base_url, url)
6264
response = super().request(method, url, *args, **kwargs)

test/retry_test.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,7 @@
77
SERVICE_UNAVAILABLE = (503, "Service Unavailable")
88
DEVICES = (200, {"devices": [{"device_id": "august_device_1"}]})
99

10-
# The retries option is currently ignored: SeamHttpClient sets self.retries after
11-
# calling niquests.Session.__init__ without forwarding it, so the mounted
12-
# HTTPAdapter keeps its default max_retries. Tests that depend on the option
13-
# being honored are marked xfail until seam/client.py passes retries through.
14-
retries_are_ignored = pytest.mark.xfail(
15-
strict=True,
16-
reason="SeamHttpClient does not forward retries to niquests.Session.",
17-
)
1810

19-
20-
@retries_are_ignored
2111
def test_seam_retries_service_unavailable_responses(recording_server):
2212
expected_retry_count = 2
2313
responses = [SERVICE_UNAVAILABLE, SERVICE_UNAVAILABLE, DEVICES]
@@ -34,7 +24,6 @@ def test_seam_retries_service_unavailable_responses(recording_server):
3424
assert len(requests) == expected_retry_count + 1
3525

3626

37-
@retries_are_ignored
3827
def test_seam_stops_retrying_once_retries_are_exhausted(recording_server):
3928
expected_retry_count = 1
4029

0 commit comments

Comments
 (0)