Home > front end >  How to implement a process to run every 5 minutes inside a flask server to check everything is okay?
How to implement a process to run every 5 minutes inside a flask server to check everything is okay?

Time:11-14

I have a web interface built by flask which needs to flush one of its dictionaries every 5 minutes. How can I code this feature in? I have looked up threading, multiprocessing and Asyncio almost all examples are about complicated stuff and none of them is relevant to my very simple basic need.

CodePudding user response:

Advanced Python Scheduler can do this for you and it is easy to use. It runs within the application and runs jobs that you schedule at intervals.

job = scheduler.add_job(myfunc, 'interval', minutes=5)

The documentations are clear and easy to setup. Also you can find Flask-APScheduler which is almost the same with few flask features.

  • Related