【Apscheduler】不生效也不报错,提示No handlers could be found for logger “apscheduler.executors.default”
生活随笔
收集整理的這篇文章主要介紹了
【Apscheduler】不生效也不报错,提示No handlers could be found for logger “apscheduler.executors.default”
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
寫代碼最怕的是,語句既不生效,也不報(bào)錯(cuò)。。
Apscheduler中添加如下代碼
from apscheduler.schedulers.blocking import BlockingSchedulerimport logging logging.basicConfig()作用:Call logging.basicConfig() before instantiating the scheduler. That lets you see what the real problem is.
就可以正常看到報(bào)錯(cuò)信息了
不完整示例
#!/usr/bin/env python # encoding:utf-8 import datetime import sysfrom apscheduler.schedulers.blocking import BlockingScheduler from app.job.core import test_print from apscheduler.schedulers.blocking import BlockingSchedulerimport logginglogging.basicConfig() sched = BlockingScheduler()def my_job(text):print(text)def job_function():print("This is job_function")test_print()sys.stdout.flush()# 在2014-05-30 00:00:00前,每周一到每周五 5:30運(yùn)行 # sched.add_job(job_function, 'cron', day_of_week='mon-fri', hour=21, minute=22, end_date='2022-01-01') sched.add_job(job_function, 'interval', seconds=2)sched.start()總結(jié)
以上是生活随笔為你收集整理的【Apscheduler】不生效也不报错,提示No handlers could be found for logger “apscheduler.executors.default”的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CentOS7升级Python2.7.5
- 下一篇: 【Docker】安装与常用命令