'APScheduler ID not found?
Can date scheduled jobs have IDS? I don't know what I am doing wrong but whenever I run this code, I get the error:
apscheduler.jobstores.base.JobLookupError: 'No job by the id of item_last_run was found'
from apscheduler.schedulers.background import BackgroundScheduler
from datetime import datetime, timedelta
scheduler = BackgroundScheduler(timezone="America/New_York")
message = "test"
def display_message():
print(message)
scheduler.remove_job('item_last_run')
scheduler_date = datetime.now() + timedelta(seconds = 3 )
print(f"\n\n***********SCHEDULED JOB FOR {scheduler_date}")
scheduler.add_job(display_message, 'date', run_date=scheduler_date, id='item_last_run')
scheduler.start()
Solution 1:[1]
Try to put a time.sleep() before calling the remove_job() function. I had the same issue and added a time.sleep(1) before it actually worked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kai - Kazuya Ito |
