Reputation: 432
We are using Mysql to store scheduler jobs using JobStores in Apscheduler 3.3.1. Job is getting stored in db as blob but apscheduler is not running the job.. Apscheduler Shows job getting added but doesn't give any indication of error or anything... Job that I am adding:
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)
Upvotes: 1
Views: 3132