Skip to content

Commit 97aae1f

Browse files
committed
Cleanup boundary checks on max-retries
1 parent 21a242c commit 97aae1f

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

jupyter_server/gateway/gateway_client.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,7 @@ class RetryableHTTPClient:
430430
MAX_RETRIES_DEFAULT = 2
431431
MAX_RETRIES_CAP = 10 # The upper limit to max_retries value.
432432
max_retries: int = int(os.getenv("JUPYTER_GATEWAY_MAX_REQUEST_RETRIES", MAX_RETRIES_DEFAULT))
433-
if max_retries < 0:
434-
max_retries = 0
435-
elif max_retries > MAX_RETRIES_CAP:
436-
max_retries = MAX_RETRIES_CAP
433+
max_retries = max(0, min(max_retries, MAX_RETRIES_CAP)) # Enforce boundaries
437434
retried_methods: ty.Set[str] = {"GET", "DELETE"}
438435
retried_errors: ty.Set[int] = {502, 503, 504, 599}
439436
retried_exceptions: ty.Set[type] = {ConnectionError}

0 commit comments

Comments
 (0)