Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
449 views
in Technique[技术] by (71.8m points)

python - Blocking scheduler(apscheduler) cannot get the job list before starting

I am unable to get the job list before I start blockingscheduler, I already have a job with id as

background_event_publisher

Now when I try to add -

jobstores = {
        'default': SQLAlchemyJobStore(url=os.environ.get("SQLALCHEMY_DATABASE_URI", None))
    }
scheduler = BlockingScheduler(
        daemon=True, jobstores=jobstores, timezone=pytz.utc)
scheduler.get_jobs()

Gives

[]

Then

scheduler.add_job(fun, 'cron', hour='09', minute='30',
                                   id='background_event_publisher' , misfire_grace_time=3600)
scheduler.start()

Gives Error

apscheduler.jobstores.base.ConflictingIdError: 'Job identifier (background_event_publisher) conflicts with an existing job

    

Can't understand why are not getting anything in get_jobs() while it still exists.

question from:https://stackoverflow.com/questions/66061653/blocking-schedulerapscheduler-cannot-get-the-job-list-before-starting

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Before the scheduler has started, it only sees jobs tentatively added to it. It cannot access the job store because the job store is only initialized during scheduler initialization. If you need to just retrieve such information without actually running the scheduled jobs, you should start the scheduler in paused state (scheduler.start(paused=True)).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...