Closed
Description
I had a doubt, about using flask-apscheduler in a web app
When used in any forking web server (gunicorn uwsgi, etc...), processes get forked, thus apacheduler gets instantiated (and possibly started) in each forked worker process. This leads to the "many jobs running" issue?
In production multiple instances of the app gets created, it will initiate that many scheduler instances also right? so all those instances will try executing the job is it?
Am I wrong here?
Activity
viniciuschiele commentedon Aug 16, 2017
yeah, your assumption is right, it will start one scheduler for each forked process and it will run the same job multiple times.
If you are running this service on multiple servers, you could keep only one active and the others as idle,
we achieved it using uwsgi legion.
everhopingandwaiting commentedon Sep 1, 2017
before start the program ,you had better to
export scheduler_lock="1"
shr-chauhan commentedon Sep 1, 2017
Sorry for the late update
@everhopingandwaiting yea that is one way of doing it, but I am doing it differently
Running scheduler as a rpc server outside the app, so its a different process now....so whenever there is a scheduling request, it gets connected to the rpc and process the request there....
@viniciuschiele closing this
everhopingandwaiting commentedon Sep 2, 2017
@viniciuschiele @viniciuschiele fcntl mscvrt
chenxuewen commentedon Aug 13, 2020
Why did you add this code? Unable to dynamically modify timing tasks?
import atexit
import fcntl
from apscheduler.events import EVENT_JOB_ERROR, EVENT_JOB_MISSED, EVENT_JOB_EXECUTED
def scheduler_init(app):