我们正在使用Mysql在Apscheduler 3.3.1中使用JobStore存储调度程序作业。 作为blob存储在db中,但是apscheduler没有运行该作业。 Apscheduler显示添加的作业,但没有给出任何错误或任何迹象...... 我要补充的工作:
run.py
jobstores =
{
'default': SQLAlchemyJobStore(url="mysql+pymysql://root:XXXXX@localhost/XXXX",tablename='apscheduler_jobs')
}
executors =
{
'default': ThreadPoolExecutor(20),
'processpool': ProcessPoolExecutor(5)
}
job_defaults =
{
'coalesce': False,
'max_instances': 3
}
scheduler = BackgroundScheduler(jobstores=jobstores,
executors=executors,
job_defaults=job_defaults)
scheduler.start()
if __name__=="__main__":
app.run()
add_job.py
from app.run import app
def my_decorator():
# phase status written in file
new_path = '/home/admin1/testing.txt'
new_days = open(new_path, 'a')
new_days.write("teting added\n")
new_days.close()
@app.route(/add_job)
def add_cron_job(self,scheduler):
# add delay in app.config method then access here
# app.config['email_campaing_delay']
job_id = str(uuid.uuid1())
job = scheduler.add_job(my_decorator,
trigger='cron',
args=[],
id=job_id,
# max_instances=1,
second='*/5',
jobstore='default')
print('added job in the background scheduler------', job.id)
scheduler.print_jobs()
try:
scheduler.start()
print('scheduler started')
except Exception as e:
print('Exception from add_cron_job is =====', e)