mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
25 lines
643 B
Python
25 lines
643 B
Python
import logging
|
|
import sys
|
|
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
|
scheduler: BackgroundScheduler = None
|
|
|
|
|
|
def initialize_scheduler():
|
|
from .appconfig import settings
|
|
global scheduler
|
|
|
|
logger = logging.getLogger('scheduler')
|
|
executors = {
|
|
'default': {
|
|
'type': 'threadpool',
|
|
'max_workers': settings.getint('global', 'SchedulerConcurrency')
|
|
}
|
|
}
|
|
job_defaults = {
|
|
'misfire_grace_time': 60 * 60 * 24 * 365 # 1 year
|
|
}
|
|
|
|
scheduler = BackgroundScheduler(logger=logger, executors=executors, job_defaults=job_defaults)
|
|
scheduler.start()
|