2018-10-10 22:43:50 +00:00
|
|
|
import logging
|
2018-10-20 22:20:31 +00:00
|
|
|
import sys
|
2018-10-10 22:43:50 +00:00
|
|
|
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
|
|
|
|
|
instance: BackgroundScheduler = None
|
|
|
|
|
|
|
|
|
|
|
|
def initialize_scheduler():
|
2018-10-20 22:37:51 +00:00
|
|
|
from .appconfig import settings
|
2018-10-10 22:43:50 +00:00
|
|
|
global instance
|
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-10-13 20:01:45 +00:00
|
|
|
'max_workers': settings.getint('global', 'SchedulerConcurrency')
|
2018-10-10 22:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 22:20:31 +00:00
|
|
|
job_defaults = {
|
|
|
|
'misfire_grace_time': sys.maxsize
|
|
|
|
}
|
2018-10-10 22:43:50 +00:00
|
|
|
|
2018-10-20 22:20:31 +00:00
|
|
|
instance = BackgroundScheduler(logger=logger, executors=executors, job_defaults=job_defaults)
|
2018-10-10 22:43:50 +00:00
|
|
|
instance.start()
|