We have a requirement to schedule multiple jobs dynamically while current job is executing.
Approximate Scenario is:
resume_dttime
resume_dttime
So the my code is:
from apscheduler.schedulers.blocking import BlockingScheduler
sched = BlockingScheduler()
@sched.scheduled_job('cron', day_of_week='mon-fri', hour=6)
def scheduled_job():
"""
"""
liveusers = todays_userslist() #Get users from table with todays resume_dttime
for u in liveusers:
user_job = get_userjob(u.id)
runtime = u.resume_dttime #eg u.resume_dttime is datetime(2015, 12, 13, 16, 30, 5)
sched.add_job(user_job, 'date', run_date=runtime, args=[u.name])
if __name__ == "__main__":
sched.start()
sched.shutdown(wait=True)
The queries are:
APScheduler 3.0 was specifically designed to efficiently handle a high volume of scheduled jobs, so I believe your intended way of using it is valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With