Ask coding questions

← Back to all posts
Asyncio.sleep() in repls
h
BBArik (0)

So here is my problem:

  • I need to set up a loop that need to work at a determined time every day.
  • I use await asyncio.sleep() for the bot to wait at a specified time and then start the task loop.
  • I try it but it never arrive to start the loop.
    If I remove the asyncio.sleep(), it works perfectly fine.
  • I feel like replit is killing my asyncio.sleep().....
    here is the code part:

Comments
hotnewtop
firefish (947)

Is this in JavaScript or Python?
Because in python you could use time.sleep() but that stops all threads

BBArik (0)

@firefish Python. I want to be sure that the thread doesnt stop so that is why I used that. I finally changed to another function (wait_until) but the question still stands to if Replit is killing long sleep time.

firefish (947)

@BBArik Hm... Do you have a backup of the repl where you used asyncio.sleep()? I might be able to help you better

BBArik (0)

@firefish It was used in a discord bot. I needed my bot to wait until a specified time to start a daily loop. I have now changed the part to use wait_until() and the code up here has been deleted. I have three options:
1 - Using other commands of my bot killed the sleep function.
2 - Replit killed my sleep function because it was taking too long.
3 - My implementation was trash and it didnt waited the specified time.
Anyway, I changed to 'wait_until', who does the calculations for me and I don't need to stress about asyncio.sleep() not working.