Forums

How to make a constant loop that fires every second (without sleep or threading)?

Hi! I am creating a new website (online web game) which requires a constant loop on the backend which fires every second, on my computer I had done it using Threading.Timer(1, countTimer).start(), but when I've done my research now it seems like pythonanywhere doesn't support Threading.

I can't use Time.sleep since that freezes the entire program and other stuff needsto run in the same file.

The file where the loop is would obviously be a always on task.

I have been confused for hours as to why it wasn't working until I found out you didn't support threading.

So basically, how should I go about making a function trigger every second on my backend, without also freezing the entire thing? Thank you!

You can run a while loop in your AlwaysOn task.