ahmer64 commited on
Commit
ed823ac
·
verified ·
1 Parent(s): c41c08c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -85,26 +85,26 @@ def run_and_submit_all(profile):
85
  agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
86
  print(agent_code)
87
 
88
- # 2. Fetch Questions
89
  print(f"Fetching questions from: {questions_url}")
90
  try:
91
- response = requests.get(questions_url, timeout=15)
 
 
 
 
 
 
 
 
92
  response.raise_for_status()
93
  questions_data = response.json()
 
94
  if not questions_data:
95
- print("Fetched questions list is empty.")
96
- return "Fetched questions list is empty or invalid format.", None
 
97
  print(f"Fetched {len(questions_data)} questions.")
98
- except requests.exceptions.RequestException as e:
99
- print(f"Error fetching questions: {e}")
100
- return f"Error fetching questions: {e}", None
101
- except requests.exceptions.JSONDecodeError as e:
102
- print(f"Error decoding JSON response from questions endpoint: {e}")
103
- print(f"Response text: {response.text[:500]}")
104
- return f"Error decoding server response for questions: {e}", None
105
- except Exception as e:
106
- print(f"An unexpected error occurred fetching questions: {e}")
107
- return f"An unexpected error occurred fetching questions: {e}", None
108
 
109
  # 3. Run your Agent
110
  results_log = []
 
85
  agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main"
86
  print(agent_code)
87
 
88
+ # 2. Fetch Questions
89
  print(f"Fetching questions from: {questions_url}")
90
  try:
91
+ import time
92
+
93
+ for attempt in range(3):
94
+ response = requests.get(questions_url, timeout=15)
95
+ if response.status_code != 429:
96
+ break
97
+ print("Rate limited. Waiting 30 seconds...")
98
+ time.sleep(30)
99
+
100
  response.raise_for_status()
101
  questions_data = response.json()
102
+
103
  if not questions_data:
104
+ print("Fetched questions list is empty.")
105
+ return "Fetched questions list is empty or invalid format.", None
106
+
107
  print(f"Fetched {len(questions_data)} questions.")
 
 
 
 
 
 
 
 
 
 
108
 
109
  # 3. Run your Agent
110
  results_log = []