Reputation: 122
I am creating a new website (online web game) which requires a constant loop on the backend which fires every second. When I was hosting 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 needs to run in the same file.
The file where the loop is would obviously be a always on task on pythonanywhere.
So basically, how should I go about making a function trigger every second on my python backend, without also freezing the entire thing, and not using any threading? Thank you!
Upvotes: 1
Views: 198
Reputation: 808
I think you are looking for Scheduled tasks.
Follow the instructions at the link and schedule your script (containing a loop in your case) to run any time you want.
Upvotes: 2