from apscheduler.schedulers.background importBackgroundScheduler, BlockingSchedulerfrom apscheduler.jobstores.redis importRedisJobStorefrom apscheduler.jobstores.sqlalchemy importSQLAlchemyJobStorefrom apscheduler.executors.pool importThreadPoolExecutor, ProcessPoolExecutordef print_args(*args):"""要定时执行的函数
:param args: 参数
:return: None"""
for arg inargs:print(arg)#执行器 常用的就线程池和进程池两种
thread_pool = ThreadPoolExecutor(30)
process_pool= ProcessPoolExecutor(5)
executors={'thread': thread_pool,'process': process_pool
}#存储器 默认使用内存,对定时任务丢失什么的不敏感,对定时任务执行要求低
redis_store = RedisJobStore(host='172.16.120.120', port='6379')
sqlite_store= SQLAlchemyJobStore(url='sqlite:///jobs.sqlite')
jobstores={'redis': redis_store,'default': sqlite_store
}#删除被持久化的定时任务