mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-07 13:59:05 +00:00
fix: add retry with delay for sandbox proxy config to avoid 500 when proxy isn't ready (#1168)
* fix: add retry with delay for sandbox proxy config to avoid 500 when proxy isn't ready * fix: add retry with exponential backoff and connection error handling for proxy config
This commit is contained in:
parent
6305e13dc6
commit
e25b158218
1 changed files with 32 additions and 6 deletions
|
|
@ -69,13 +69,39 @@ def _configure_github_proxy(sandbox_name: str, github_token: str) -> None:
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
max_retries = 3
|
||||||
|
retry_delay = 5
|
||||||
with httpx.Client() as client:
|
with httpx.Client() as client:
|
||||||
response = client.patch(
|
for attempt in range(max_retries):
|
||||||
url,
|
if attempt > 0:
|
||||||
json=payload,
|
time.sleep(retry_delay)
|
||||||
headers={"X-API-Key": api_key},
|
try:
|
||||||
)
|
response = client.patch(
|
||||||
response.raise_for_status()
|
url,
|
||||||
|
json=payload,
|
||||||
|
headers={"X-API-Key": api_key},
|
||||||
|
)
|
||||||
|
except httpx.HTTPError as e:
|
||||||
|
logger.warning(
|
||||||
|
"Proxy config attempt %d/%d connection error: %s",
|
||||||
|
attempt + 1,
|
||||||
|
max_retries,
|
||||||
|
e,
|
||||||
|
)
|
||||||
|
if attempt == max_retries - 1:
|
||||||
|
raise
|
||||||
|
continue
|
||||||
|
if response.is_success:
|
||||||
|
break
|
||||||
|
logger.warning(
|
||||||
|
"Proxy config attempt %d/%d failed (%s): %s",
|
||||||
|
attempt + 1,
|
||||||
|
max_retries,
|
||||||
|
response.status_code,
|
||||||
|
response.text,
|
||||||
|
)
|
||||||
|
if attempt == max_retries - 1:
|
||||||
|
response.raise_for_status()
|
||||||
logger.info("Configured GitHub proxy for sandbox %s", sandbox_name)
|
logger.info("Configured GitHub proxy for sandbox %s", sandbox_name)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue