init
This commit is contained in:
21
web/tasks/crond/__init__.py
Normal file
21
web/tasks/crond/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
import glob
|
||||
from importlib import import_module
|
||||
|
||||
from apscheduler.schedulers.blocking import BlockingScheduler
|
||||
from apscheduler.schedulers.gevent import GeventScheduler
|
||||
|
||||
from worker import ASYNC_MODE, MODE_GEVENT
|
||||
|
||||
|
||||
if ASYNC_MODE == MODE_GEVENT:
|
||||
sched = GeventScheduler(timezone="Asia/Shanghai")
|
||||
else:
|
||||
sched = BlockingScheduler(timezone="Asia/Shanghai")
|
||||
|
||||
# 定时任放到jobs里统一加载
|
||||
path = os.path.dirname(__file__)
|
||||
file_names = glob.glob(os.path.join(path, 'jobs', '*.py'))
|
||||
for filename in file_names:
|
||||
module = os.path.basename(filename)[:-3]
|
||||
import_module('.' + module, "tasks.crond.jobs")
|
Reference in New Issue
Block a user