I using Python Flask to along with apscheduler and trying to add/remove jobs as follows:-
sched = Scheduler()
sched.start()
print "Schedular Started"
def new_job():
@sched.interval_schedule(seconds=2)
def job_function():
print "Hello World"
@app.route('/add')
def add():
new_job()
return 'started'
This bit works as expected. However when I try to remove the job like this:
@app.route('/remove')
def remove():
sched.unschedule_job(job_function.job)
return "Removed"
I'm getting a "NameError: global name 'job_function' is not defined" as expected. My question is how can I remove a job from the schedular using a different route?
Regards.