__init__.py 780 Bytes
Newer Older
wanli's avatar
wanli committed
1 2 3 4 5 6 7 8 9 10 11
#!/usr/bin/env python
# -*- coding: utf_8 -*-

from app import config
from apscheduler.schedulers.background import BackgroundScheduler
# from apscheduler.jobstores.mongodb import MongoDBJobStore
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor

jobstores = {
    # 'mongo': MongoDBJobStore(),
wanli's avatar
wanli committed
12
    'default': SQLAlchemyJobStore(url='sqlite:///{}'.format("scheduler.db", engine_options={ 'connect_args': { 'timeout': 15 } })
wanli's avatar
wanli committed
13 14 15 16 17 18 19 20 21 22 23
}
executors = {
    'default': ThreadPoolExecutor(20),
    'processpool': ProcessPoolExecutor(1)
}
job_defaults = {
    'coalesce': False,
    'max_instances': 1
}
scheduler = BackgroundScheduler(executors=executors, job_defaults=job_defaults,)
scheduler.start()