Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -32,12 +32,21 @@ def run_and_submit_all(username):
|
|
32 |
if not username:
|
33 |
return "Please enter your Hugging Face username.", None
|
34 |
|
35 |
-
|
36 |
try:
|
37 |
resp = requests.get(f"{DEFAULT_API_URL}/questions", timeout=15)
|
|
|
|
|
|
|
38 |
resp.raise_for_status()
|
39 |
questions = resp.json()
|
40 |
-
except
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
return f"Error fetching questions: {e}", None
|
42 |
|
43 |
# Run agent on all questions
|
|
|
32 |
if not username:
|
33 |
return "Please enter your Hugging Face username.", None
|
34 |
|
35 |
+
# Fetch questions
|
36 |
try:
|
37 |
resp = requests.get(f"{DEFAULT_API_URL}/questions", timeout=15)
|
38 |
+
# Handle rate limiting specifically
|
39 |
+
if resp.status_code == 429:
|
40 |
+
return "Server rate limited the requests. Please wait a moment and try again.", None
|
41 |
resp.raise_for_status()
|
42 |
questions = resp.json()
|
43 |
+
except requests.exceptions.HTTPError as e:
|
44 |
+
# Specific HTTP errors not caught above
|
45 |
+
status_code = getattr(e.response, 'status_code', None)
|
46 |
+
if status_code == 429:
|
47 |
+
return "Server rate limited the requests. Please wait a moment and try again.", None
|
48 |
+
return f"Error fetching questions: {e}", None
|
49 |
+
except requests.exceptions.RequestException as e:
|
50 |
return f"Error fetching questions: {e}", None
|
51 |
|
52 |
# Run agent on all questions
|