lunarflu HF staff commited on
Commit
546104d
1 Parent(s): 7bc05e5

added sleeps

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -13,6 +13,7 @@ import asyncio
13
  import csv
14
  from tabulate import tabulate
15
  import logging
 
16
 
17
  import gradio_client
18
  import gradio as gr
@@ -64,6 +65,7 @@ processed_users = set()
64
 
65
  async def periodic_api_test():
66
  try:
 
67
  column_values_3 = worksheet2.col_values(3)
68
  column_values_8 = worksheet2.col_values(8)
69
 
@@ -136,6 +138,7 @@ def is_csv_empty(file_path):
136
 
137
  def blocking_io(member_id):
138
  try:
 
139
  worksheet = gspread_bot.open("levelbot").sheet1
140
 
141
  guild = bot.get_guild(879548962464493619)
@@ -180,7 +183,7 @@ def blocking_io(member_id):
180
 
181
  async def add_exp(member_id):
182
  try:
183
-
184
  loop = asyncio.get_running_loop()
185
  result = await loop.run_in_executor(None, blocking_io, member_id)
186
 
@@ -251,6 +254,7 @@ async def on_message(message):
251
  try:
252
  if message.author.id not in bot_ids:
253
  print(f"adding exp from message {message.author}")
 
254
  await add_exp(message.author.id)
255
  await periodic_api_test() # run this ~1 per day otherwise will lead to issues
256
  await bot.process_commands(message)
@@ -263,6 +267,7 @@ async def on_reaction_add(reaction, user):
263
  try:
264
  if user.id not in bot_ids:
265
  print(f"adding exp from react {user.id}")
 
266
  await add_exp(user.id)
267
  except Exception as e:
268
  print(f"on_reaction_add Error: {e}")
@@ -273,6 +278,7 @@ async def on_reaction_add(reaction, user):
273
  @bot.command(name='update_leaderboard')
274
  async def update_leaderboard(ctx, num_results: int = 10):
275
  if ctx.author.id == 811235357663297546:
 
276
  worksheet = gspread_bot.open("levelbot").sheet1
277
 
278
  names_list = worksheet.col_values(2)[1:]
 
13
  import csv
14
  from tabulate import tabulate
15
  import logging
16
+ import time
17
 
18
  import gradio_client
19
  import gradio as gr
 
65
 
66
  async def periodic_api_test():
67
  try:
68
+ asyncio.sleep(0.01)
69
  column_values_3 = worksheet2.col_values(3)
70
  column_values_8 = worksheet2.col_values(8)
71
 
 
138
 
139
  def blocking_io(member_id):
140
  try:
141
+ time.sleep(0.01)
142
  worksheet = gspread_bot.open("levelbot").sheet1
143
 
144
  guild = bot.get_guild(879548962464493619)
 
183
 
184
  async def add_exp(member_id):
185
  try:
186
+ asyncio.sleep(0.01)
187
  loop = asyncio.get_running_loop()
188
  result = await loop.run_in_executor(None, blocking_io, member_id)
189
 
 
254
  try:
255
  if message.author.id not in bot_ids:
256
  print(f"adding exp from message {message.author}")
257
+ asyncio.sleep(0.01)
258
  await add_exp(message.author.id)
259
  await periodic_api_test() # run this ~1 per day otherwise will lead to issues
260
  await bot.process_commands(message)
 
267
  try:
268
  if user.id not in bot_ids:
269
  print(f"adding exp from react {user.id}")
270
+ asyncio.sleep(0.01)
271
  await add_exp(user.id)
272
  except Exception as e:
273
  print(f"on_reaction_add Error: {e}")
 
278
  @bot.command(name='update_leaderboard')
279
  async def update_leaderboard(ctx, num_results: int = 10):
280
  if ctx.author.id == 811235357663297546:
281
+ asyncio.sleep(0.01)
282
  worksheet = gspread_bot.open("levelbot").sheet1
283
 
284
  names_list = worksheet.col_values(2)[1:]