我试图弄清楚在我使用高级Python调度器保存一些作业后,sqlite数据库的模式是什么样子的。我需要它是因为我想在UI中显示作业。我试着写一个简单的脚本来保存一份工作:
from pytz import utc
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
from datetime import datetime
import os
from apscheduler.schedulers.blocking import BlockingScheduler
jobstores = {
'default': SQLAlchemyJobStore(url='sqlite:///test.db')
}
executors = {
'default': ThreadPoolExecutor(20),
'processpool': ProcessPoolExecutor(5)
}
job_defaults = {
'coalesce': False,
'max_instances': 3
}
scheduler = BackgroundScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults, timezone=utc)
def tick():
print('Tick! The time is: %s' % datetime.now())
scheduler = BlockingScheduler()
scheduler.add_executor('processpool')
scheduler.add_job(tick, 'interval', seconds=3)
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
try:
scheduler.start()
except (keyboardInterrupt, SystemExit):
pass
但是终端中的“.fullschema”命令显示,在测试数据库. 我到底做错了什么?在
您正在创建两个调度程序,但只启动具有默认配置的调度程序。在
相关问题 更多 >
编程相关推荐