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
4 changes: 2 additions & 2 deletions src/runloop_api_client/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
DEFAULT_MAX_RETRIES = 0
DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)

INITIAL_RETRY_DELAY = 0.5
MAX_RETRY_DELAY = 8.0
INITIAL_RETRY_DELAY = 1.0
MAX_RETRY_DELAY = 5.0
48 changes: 24 additions & 24 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,20 +706,20 @@ class Model(BaseModel):
"remaining_retries,retry_after,timeout",
[
[3, "20", 20],
[3, "0", 0.5],
[3, "-10", 0.5],
[3, "0", 1],
[3, "-10", 1],
[3, "60", 60],
[3, "61", 0.5],
[3, "61", 1],
[3, "Fri, 29 Sep 2023 16:26:57 GMT", 20],
[3, "Fri, 29 Sep 2023 16:26:37 GMT", 0.5],
[3, "Fri, 29 Sep 2023 16:26:27 GMT", 0.5],
[3, "Fri, 29 Sep 2023 16:26:37 GMT", 1],
[3, "Fri, 29 Sep 2023 16:26:27 GMT", 1],
[3, "Fri, 29 Sep 2023 16:27:37 GMT", 60],
[3, "Fri, 29 Sep 2023 16:27:38 GMT", 0.5],
[3, "99999999999999999999999999999999999", 0.5],
[3, "Zun, 29 Sep 2023 16:26:27 GMT", 0.5],
[3, "", 0.5],
[2, "", 0.5 * 2.0],
[1, "", 0.5 * 4.0],
[3, "Fri, 29 Sep 2023 16:27:38 GMT", 1],
[3, "99999999999999999999999999999999999", 1],
[3, "Zun, 29 Sep 2023 16:26:27 GMT", 1],
[3, "", 1],
[2, "", 1 * 2.0],
[1, "", 1 * 4.0],
],
)
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
Expand All @@ -729,7 +729,7 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str
headers = httpx.Headers({"retry-after": retry_after})
options = FinalRequestOptions(method="get", url="/foo", max_retries=3)
calculated = client._calculate_retry_timeout(remaining_retries, options, headers)
assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]
assert calculated == pytest.approx(timeout, 1 * 0.875) # pyright: ignore[reportUnknownMemberType]

@mock.patch("runloop_api_client._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
Expand Down Expand Up @@ -1442,20 +1442,20 @@ class Model(BaseModel):
"remaining_retries,retry_after,timeout",
[
[3, "20", 20],
[3, "0", 0.5],
[3, "-10", 0.5],
[3, "0", 1],
[3, "-10", 1],
[3, "60", 60],
[3, "61", 0.5],
[3, "61", 1],
[3, "Fri, 29 Sep 2023 16:26:57 GMT", 20],
[3, "Fri, 29 Sep 2023 16:26:37 GMT", 0.5],
[3, "Fri, 29 Sep 2023 16:26:27 GMT", 0.5],
[3, "Fri, 29 Sep 2023 16:26:37 GMT", 1],
[3, "Fri, 29 Sep 2023 16:26:27 GMT", 1],
[3, "Fri, 29 Sep 2023 16:27:37 GMT", 60],
[3, "Fri, 29 Sep 2023 16:27:38 GMT", 0.5],
[3, "99999999999999999999999999999999999", 0.5],
[3, "Zun, 29 Sep 2023 16:26:27 GMT", 0.5],
[3, "", 0.5],
[2, "", 0.5 * 2.0],
[1, "", 0.5 * 4.0],
[3, "Fri, 29 Sep 2023 16:27:38 GMT", 1],
[3, "99999999999999999999999999999999999", 1],
[3, "Zun, 29 Sep 2023 16:26:27 GMT", 1],
[3, "", 1],
[2, "", 1 * 2.0],
[1, "", 1 * 4.0],
],
)
@mock.patch("time.time", mock.MagicMock(return_value=1696004797))
Expand All @@ -1466,7 +1466,7 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte
headers = httpx.Headers({"retry-after": retry_after})
options = FinalRequestOptions(method="get", url="/foo", max_retries=3)
calculated = client._calculate_retry_timeout(remaining_retries, options, headers)
assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType]
assert calculated == pytest.approx(timeout, 1 * 0.875) # pyright: ignore[reportUnknownMemberType]

@mock.patch("runloop_api_client._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout)
@pytest.mark.respx(base_url=base_url)
Expand Down