Spaces:
Runtime error
Runtime error
fix 503
Browse files- pages/base_page.py +14 -1
pages/base_page.py
CHANGED
|
@@ -19,7 +19,7 @@ class AbstractPage(ABC):
|
|
| 19 |
|
| 20 |
|
| 21 |
class BasePage(AbstractPage):
|
| 22 |
-
base_url = "https://apis.skyreels.ai
|
| 23 |
token = ""
|
| 24 |
poll_interval = 5
|
| 25 |
loop_limit = 2000
|
|
@@ -92,6 +92,19 @@ class BasePage(AbstractPage):
|
|
| 92 |
headers["Authorization"] = self.token
|
| 93 |
|
| 94 |
response = requests.get(query_url, headers=headers, timeout=30)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
response.raise_for_status()
|
| 96 |
return response.json()
|
| 97 |
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
class BasePage(AbstractPage):
|
| 22 |
+
base_url = "https://apis.skyreels.ai"
|
| 23 |
token = ""
|
| 24 |
poll_interval = 5
|
| 25 |
loop_limit = 2000
|
|
|
|
| 92 |
headers["Authorization"] = self.token
|
| 93 |
|
| 94 |
response = requests.get(query_url, headers=headers, timeout=30)
|
| 95 |
+
|
| 96 |
+
if response.status_code == 503:
|
| 97 |
+
try:
|
| 98 |
+
# Try to parse specific error detail from 503 response
|
| 99 |
+
error_body = response.json()
|
| 100 |
+
detail = error_body.get("detail")
|
| 101 |
+
if detail:
|
| 102 |
+
# Return failed status directly to stop retrying
|
| 103 |
+
return {"status": "failed", "msg": detail}
|
| 104 |
+
except Exception:
|
| 105 |
+
# If parsing fails, fall back to raising HTTP error
|
| 106 |
+
pass
|
| 107 |
+
|
| 108 |
response.raise_for_status()
|
| 109 |
return response.json()
|
| 110 |
|