Skip to content

Commit 615c232

Browse files
init
1 parent 7526908 commit 615c232

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/parallel/lib/_time.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def _raise_timeout(run_id: str, exc: Union[Exception, None]) -> NoReturn:
2828
raise TimeoutError(f"Fetching task run result for run id {run_id} timed out.") from exc
2929

3030

31+
def _is_retryable_error(status_code: int) -> bool:
32+
"""Determine if an error is retryable."""
33+
return status_code in (408, 503, 504)
34+
35+
3136
@contextlib.contextmanager
3237
def timeout_retry_context(run_id: str, deadline: float) -> Iterator[None]:
3338
"""Context manager for handling timeouts and retries when fetching task run results.
@@ -49,8 +54,7 @@ def timeout_retry_context(run_id: str, deadline: float) -> Iterator[None]:
4954
exc = e
5055
continue
5156
except APIStatusError as e:
52-
# retry on timeouts from the API
53-
if e.status_code == 408:
57+
if _is_retryable_error(e.status_code):
5458
exc = e
5559
continue
5660
raise

0 commit comments

Comments
 (0)