|
I'm attempting to run multiple AP Scheduler jobs in my program (both interval and cron) but when I add multiple interval jobs with different intervals they all execute at the shortest interval. For example, I add one job with a frequency of 30 seconds and one with 15 seconds, both will execute every 15 seconds. My code is below. How do I properly run these two jobs on separate intervals? |
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.executors.pool import ProcessPoolExecutor
executors = {
'default': {'type': 'threadpool', 'max_workers': 20},
'processpool': ProcessPoolExecutor(max_workers=5)
}
job_defaults = {
'coalesce': False,
'max_instances': 3
}
sched = BackgroundScheduler(executors=executors, job_defaults=job_defaults, timezone="EST", daemon=True))
sched.start()
sched.add_job(lambda: module.handle(self.profile, mic), 'interval', id=module.__name__, seconds=15)
sched.add_job(lambda: module2.handle(self.profile, mic), 'interval', id=module2.__name__, seconds=30)
atexit.register(lambda: sched.shutdown(wait=False))
--
You received this message because you are subscribed to the Google Groups "APScheduler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
sched.add_job(module.handle, 'interval', args=[self.profile, mic], id=module.__name__, seconds=15) sched.add_job(module2.handle, 'interval', args=[self.profile, mic], id=module2.__name__, seconds=30)