2018-10-10 22:43:50 +00:00
|
|
|
import logging
|
2018-12-10 21:23:00 +00:00
|
|
|
|
2018-10-10 22:43:50 +00:00
|
|
|
from apscheduler.schedulers.background import BackgroundScheduler
|
2018-12-10 21:23:00 +00:00
|
|
|
|
|
|
|
from YtManagerApp.management.appconfig import global_prefs
|
2018-10-10 22:43:50 +00:00
|
|
|
|
2018-10-29 16:52:09 +00:00
|
|
|
scheduler: BackgroundScheduler = None
|
2018-10-10 22:43:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
def initialize_scheduler():
|
2018-10-29 16:52:09 +00:00
|
|
|
global scheduler
|
2018-10-20 22:37:51 +00:00
|
|
|
|
2018-10-10 22:43:50 +00:00
|
|
|
logger = logging.getLogger('scheduler')
|
|
|
|
executors = {
|
|
|
|
'default': {
|
|
|
|
'type': 'threadpool',
|
2018-12-10 21:23:00 +00:00
|
|
|
'max_workers': global_prefs['scheduler__concurrency']
|
2018-10-10 22:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 22:20:31 +00:00
|
|
|
job_defaults = {
|
2018-10-29 16:52:09 +00:00
|
|
|
'misfire_grace_time': 60 * 60 * 24 * 365 # 1 year
|
2018-10-20 22:20:31 +00:00
|
|
|
}
|
2018-10-10 22:43:50 +00:00
|
|
|
|
2018-10-29 16:52:09 +00:00
|
|
|
scheduler = BackgroundScheduler(logger=logger, executors=executors, job_defaults=job_defaults)
|
|
|
|
scheduler.start()
|