Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
try tasks.loop instead (no direct interaction with google sheet, so shouldn't have hearbeat blocked issues)
Browse files
app.py
CHANGED
|
@@ -126,8 +126,10 @@ async def on_ready():
|
|
| 126 |
global_df = test_merge
|
| 127 |
print(f"csv successfully retrieved: \n {global_df}")
|
| 128 |
|
|
|
|
| 129 |
# updates both leaderboards
|
| 130 |
remove_huggingfolks.start()
|
|
|
|
| 131 |
print("------------------------------------------------------------------------")
|
| 132 |
except Exception as e:
|
| 133 |
print(f"on_ready Error: {e}")
|
|
@@ -147,6 +149,7 @@ def update_google_sheet():
|
|
| 147 |
except Exception as e:
|
| 148 |
print(f"update_google_sheet Error: {e}")
|
| 149 |
|
|
|
|
| 150 |
#@tasks.loop(minutes=1) tasks.loop leads to heartbeat blocked issues (merging calculations too much with normal discord bot functions)
|
| 151 |
def update_hub_stats():
|
| 152 |
try:
|
|
@@ -216,6 +219,7 @@ def update_hub_stats():
|
|
| 216 |
print("------------------------------------------------------------------------")
|
| 217 |
|
| 218 |
|
|
|
|
| 219 |
async def give_verified_roles():
|
| 220 |
global global_df
|
| 221 |
for index, row in global_df.iterrows():
|
|
@@ -234,15 +238,14 @@ async def give_verified_roles():
|
|
| 234 |
|
| 235 |
thread_pool_executor = ThreadPoolExecutor(max_workers=2)
|
| 236 |
asyncio_executor = AsyncIOExecutor()
|
| 237 |
-
scheduler =
|
| 238 |
-
'default': thread_pool_executor
|
| 239 |
-
'asyncio': asyncio_executor
|
| 240 |
})
|
| 241 |
scheduler.add_job(update_google_sheet, trigger='interval', minutes=1, max_instances=2, executor='default')
|
| 242 |
scheduler.add_job(update_hub_stats, trigger='interval', minutes=1.5, max_instances=2, executor='default')
|
| 243 |
-
scheduler.add_job(give_verified_roles, trigger='interval', minutes=1, max_instances=1, executor='asyncio')
|
| 244 |
scheduler.start()
|
| 245 |
-
asyncio.get_event_loop().run_forever()
|
| 246 |
|
| 247 |
|
| 248 |
def calculate_level(xp):
|
|
|
|
| 126 |
global_df = test_merge
|
| 127 |
print(f"csv successfully retrieved: \n {global_df}")
|
| 128 |
|
| 129 |
+
|
| 130 |
# updates both leaderboards
|
| 131 |
remove_huggingfolks.start()
|
| 132 |
+
give_verified_roles.start()
|
| 133 |
print("------------------------------------------------------------------------")
|
| 134 |
except Exception as e:
|
| 135 |
print(f"on_ready Error: {e}")
|
|
|
|
| 149 |
except Exception as e:
|
| 150 |
print(f"update_google_sheet Error: {e}")
|
| 151 |
|
| 152 |
+
|
| 153 |
#@tasks.loop(minutes=1) tasks.loop leads to heartbeat blocked issues (merging calculations too much with normal discord bot functions)
|
| 154 |
def update_hub_stats():
|
| 155 |
try:
|
|
|
|
| 219 |
print("------------------------------------------------------------------------")
|
| 220 |
|
| 221 |
|
| 222 |
+
@tasks.loop(minutes=1)
|
| 223 |
async def give_verified_roles():
|
| 224 |
global global_df
|
| 225 |
for index, row in global_df.iterrows():
|
|
|
|
| 238 |
|
| 239 |
thread_pool_executor = ThreadPoolExecutor(max_workers=2)
|
| 240 |
asyncio_executor = AsyncIOExecutor()
|
| 241 |
+
scheduler = BackgroundScheduler(executors={
|
| 242 |
+
'default': thread_pool_executor
|
|
|
|
| 243 |
})
|
| 244 |
scheduler.add_job(update_google_sheet, trigger='interval', minutes=1, max_instances=2, executor='default')
|
| 245 |
scheduler.add_job(update_hub_stats, trigger='interval', minutes=1.5, max_instances=2, executor='default')
|
| 246 |
+
#scheduler.add_job(give_verified_roles, trigger='interval', minutes=1, max_instances=1, executor='asyncio')
|
| 247 |
scheduler.start()
|
| 248 |
+
#asyncio.get_event_loop().run_forever()
|
| 249 |
|
| 250 |
|
| 251 |
def calculate_level(xp):
|