You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library looks promising for scheduling cron jobs from python. This centralizes all of the cron work. If a cron job changes or gets renamed or whatever, a migration script can be written.
The text was updated successfully, but these errors were encountered:
I'm using https://pypi.python.org/pypi/APScheduler in another project and it works really well for me. There's a flask extension but I'm not a big fan of how it is configured. However, since it's all happening outside the request context, you don't really need to integrate it with Flask, I just run it in the main application loop and it works fine, logs to stdout like you would expect. With the cron scheduler you don't even really need a message queue for this, can just use the in-memory one.
The nice thing about a pure python implementation is that it makes it easy to deploy the application in Heroku and such.
Check it out and tell me what you think, here's some example code. The task runners take the Flask app object as an argument so they can have the config:
defstart_and_run_scheduler(app):
defassignments(app):
assign_hosts_to_teams(app)
assign_users_to_teams(app)
sched=BackgroundScheduler()
# Every hour at :10sched.add_job(assignments, 'cron', minute=10, args=(app,),)
# Every day at Midnightsched.add_job(fill_ddi_cache, 'cron', hour=0, minute=0, args=(app,), )
sched.start()
logger.info('Started task scheduler')
This library looks promising for scheduling cron jobs from python. This centralizes all of the cron work. If a cron job changes or gets renamed or whatever, a migration script can be written.
The text was updated successfully, but these errors were encountered: