-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
29 lines (23 loc) · 841 Bytes
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from pytz import timezone
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.mongodb import MongoDBJobStore, MongoClient
from apscheduler.executors.pool import ThreadPoolExecutor
from appname import create_app
app = create_app('appname.config.BaseConfig')
jobstores = {
'default': MongoDBJobStore(client=MongoClient(app.config.get('MONGO_URI'))),
}
executors = {
'default': ThreadPoolExecutor(20)
}
job_defaults = {
'coalesce': False,
'max_instances': 5
}
scheduler_tz = timezone(app.config["TIME_ZONE"])
scheduler = BackgroundScheduler(jobstores=jobstores,
executors=executors,
job_defaults=job_defaults,
timezone=scheduler_tz)
scheduler.start()
app.scheduler = scheduler