Answer the question
In order to leave comments, you need to log in
How to implement periodic jobs in python/flask?
There is such a micro-project on the flask micro-framework. There was a need for periodic cron-like jobs, with the ability to flexibly control this matter (change the interval or suspend the job altogether).
I have seen this many times on production servers, and I don’t want to do this:
*/10 * * * * /var/www/project/tasks.py
Answer the question
In order to leave comments, you need to log in
If you don't like unix cron and celery, the only option seems to be to write your own cron service.
In this case, the format for describing tasks can be more human. Yes, and overhead on the generation of processes can be avoided.
For example, the developers of Google App Engine did just that:
https://developers.google.com/appengine/docs/pytho...
I remember writing a simple script that parsed files similar to crontab and started tasks under Windows. This had to be done, because. The task scheduler under Windows is a very crooked and unreliable animal. My Python script registered as a Windows service and worked for 3 years without any problems, while doing its job.
You need a delayed delivery message queue. Beanstalk and RabbitMQ can do this with a clever hack.
I tried to tie Celery, but it looked like a crutch, and I wrote a very primitive algorithm for running tasks inside the Flask application, saving intermediate execution information in an existing database. Tasks are executed in separate threads.
Minimal overhead and 100 more lines of code to synchronize and restore tasks after uwsgi down.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question