25 lines
775 B
Python
25 lines
775 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
|
|
|
|
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
|
|
|
|
|
|
# apscheduler的配置
|
|
class ApschedulerConfig:
|
|
url = f"mysql+pymysql://root:123456@127.0.0.1:3306/base_platform?charset=utf8" # 使用pymysql连接数据库,字符集为UTF8
|
|
|
|
job_stores = {
|
|
'default': SQLAlchemyJobStore(url=url, tablename='apscheduler_task') # 定时任务表名为my_tasks
|
|
}
|
|
executors = {
|
|
'default': ThreadPoolExecutor(20),
|
|
'processpool': ProcessPoolExecutor(5)
|
|
}
|
|
job_defaults = {
|
|
'coalesce': True, # 堆积后只执行最后一个
|
|
'max_instances': 1, # 最大的实例只能存在一个
|
|
|
|
}
|