Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -63,6 +63,7 @@ def _request_with_retry(url: str, params: dict = None, max_retries: int = 3, bac
|
|
| 63 |
Returns a requests.Response object or raises the last exception.
|
| 64 |
"""
|
| 65 |
attempt = 0
|
|
|
|
| 66 |
while attempt < max_retries:
|
| 67 |
try:
|
| 68 |
resp = requests.get(url, headers=HEADERS, params=params, timeout=10)
|
|
@@ -74,12 +75,13 @@ def _request_with_retry(url: str, params: dict = None, max_retries: int = 3, bac
|
|
| 74 |
continue
|
| 75 |
return resp
|
| 76 |
except Exception as e:
|
| 77 |
-
|
| 78 |
time.sleep(backoff_factor)
|
| 79 |
attempt += 1
|
| 80 |
-
last_err = e
|
| 81 |
# If we exit the loop without returning, raise the last error
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
|
| 84 |
# ----------------------------------------------------------------------
|
| 85 |
# Core functions
|
|
|
|
| 63 |
Returns a requests.Response object or raises the last exception.
|
| 64 |
"""
|
| 65 |
attempt = 0
|
| 66 |
+
last_err = None
|
| 67 |
while attempt < max_retries:
|
| 68 |
try:
|
| 69 |
resp = requests.get(url, headers=HEADERS, params=params, timeout=10)
|
|
|
|
| 75 |
continue
|
| 76 |
return resp
|
| 77 |
except Exception as e:
|
| 78 |
+
last_err = e
|
| 79 |
time.sleep(backoff_factor)
|
| 80 |
attempt += 1
|
|
|
|
| 81 |
# If we exit the loop without returning, raise the last error
|
| 82 |
+
if last_err:
|
| 83 |
+
raise last_err
|
| 84 |
+
raise RuntimeError("Request failed after retries without a captured exception.")
|
| 85 |
|
| 86 |
# ----------------------------------------------------------------------
|
| 87 |
# Core functions
|