job_stores = {
'default': MongoDBJobStore(database=databasename,
client=clientname, collection="schedulejob")
}
executors = {
'default': {'type': 'threadpool', 'max_workers': 5}
}
job_defaults = {
'coalesce': True, # When the same task is triggered multiple times at the same time, it runs only once
'max_instances': 3,
'misfire_grace_time': 3600, # The task is still executed after 30 seconds of expiration
}
global sched
sched = BackgroundScheduler(jobstores=job_stores, executors=executors, job_defaults=job_defaults, daemon=True)
sched.add_job(helloworld, 'interval', hours=3, args=(),
name=name)
I can see schedulejob is created with single entry, but on respective timestamp, my same function helloworld got executed four times.
Note: I am using Flask server with 4 nodes. Is the four nodes being the reason.