I want my flask server to do a certain task when its idle for some time lets say 5 mins, i.e after 5 mins it will do another job. For this i need something to check if a server is busy or idle. How can I achieve this?
Asked
Active
Viewed 762 times
1 Answers
0
You can save the current datetime in a variable everytime a request is made via the @app.after_request
annotation.
Then you need a routine to periodically check if the time difference between now and the saved timestamp is greater than 5 miutes. If so then run your task.
For executing your check every 5 minutes you may need some kind of scheduler which will be started with your application.
-
Can you please elaborate more about the routine and scheduler. Thanks – gg-dev-05 Jun 16 '20 at 15:00