ytsm/app/YtManagerApp/scheduler.py

28 lines
631 B
Python
Raw Normal View History

2018-10-10 22:43:50 +00:00
import logging
2018-10-10 22:43:50 +00:00
from apscheduler.schedulers.background import BackgroundScheduler
from YtManagerApp.management.appconfig import appconfig
2018-10-10 22:43:50 +00:00
scheduler = BackgroundScheduler()
2018-10-10 22:43:50 +00:00
def initialize_scheduler():
if scheduler.running:
return
2018-10-10 22:43:50 +00:00
logger = logging.getLogger('scheduler')
executors = {
'default': {
'type': 'threadpool',
'max_workers': appconfig.concurrency
2018-10-10 22:43:50 +00:00
}
}
job_defaults = {
'misfire_grace_time': 60 * 60 * 24 * 365 # 1 year
}
2018-10-10 22:43:50 +00:00
scheduler.configure(logger=logger, executors=executors, job_defaults=job_defaults)
scheduler.start()