Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
fix
Browse files
app.py
CHANGED
@@ -136,6 +136,8 @@ async def on_ready():
|
|
136 |
|
137 |
def update_google_sheet():
|
138 |
"""save data from HF Space -> google sheets (makes 1 API call)"""
|
|
|
|
|
139 |
try:
|
140 |
print("Updating google sheets...")
|
141 |
print("------------------------------------------------------------------------")
|
@@ -146,6 +148,8 @@ def update_google_sheet():
|
|
146 |
print("------------------------------------------------------------------------")
|
147 |
print(f"Google sheet {name} {test_merge_worksheet} successfully updated at {timestamp}! \n{global_df}")
|
148 |
print("------------------------------------------------------------------------")
|
|
|
|
|
149 |
except Exception as e:
|
150 |
print(f"update_google_sheet Error: {e}")
|
151 |
|
@@ -242,8 +246,8 @@ asyncio_executor = AsyncIOExecutor()
|
|
242 |
scheduler = BackgroundScheduler(executors={
|
243 |
'default': thread_pool_executor
|
244 |
})
|
245 |
-
scheduler.add_job(update_google_sheet, trigger='interval', minutes=1, max_instances=5, executor='default'
|
246 |
-
scheduler.add_job(update_hub_stats, trigger='interval', minutes=1.5, max_instances=5, executor='default'
|
247 |
scheduler.start()
|
248 |
#asyncio.get_event_loop().run_forever()
|
249 |
|
|
|
136 |
|
137 |
def update_google_sheet():
|
138 |
"""save data from HF Space -> google sheets (makes 1 API call)"""
|
139 |
+
start_time = time.time()
|
140 |
+
timeout = 300
|
141 |
try:
|
142 |
print("Updating google sheets...")
|
143 |
print("------------------------------------------------------------------------")
|
|
|
148 |
print("------------------------------------------------------------------------")
|
149 |
print(f"Google sheet {name} {test_merge_worksheet} successfully updated at {timestamp}! \n{global_df}")
|
150 |
print("------------------------------------------------------------------------")
|
151 |
+
if time.time() - start_time > timeout:
|
152 |
+
print(f"Job exceeded timeout of {timeout} seconds.")
|
153 |
except Exception as e:
|
154 |
print(f"update_google_sheet Error: {e}")
|
155 |
|
|
|
246 |
scheduler = BackgroundScheduler(executors={
|
247 |
'default': thread_pool_executor
|
248 |
})
|
249 |
+
scheduler.add_job(update_google_sheet, trigger='interval', minutes=1, max_instances=5, executor='default')
|
250 |
+
scheduler.add_job(update_hub_stats, trigger='interval', minutes=1.5, max_instances=5, executor='default')
|
251 |
scheduler.start()
|
252 |
#asyncio.get_event_loop().run_forever()
|
253 |
|