python apschedular RedisJobStore不在redis缓存中存储作业

问题描述 投票:0回答:1

这是我的python代码:所有作业都在正确的时间触发但不存储为redis缓存。如果重新启动程序,则无法安排挂起的作业。我做错了什么?

from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor

if __name__ == '__main__':

    jobstores = {
        'redis': RedisJobStore(jobs_key='dispatched_trips_jobs', run_times_key='dispatched_trips_running', host='localhost', port=6379)
    }
    executors = {
        'default': ThreadPoolExecutor(100),
        'processpool': ProcessPoolExecutor(5)
    }

    scheduler = BackgroundScheduler(jobstores=jobstores, executors=executors)


    scheduler.start()

    while True:
        pass
python-3.x redis apscheduler
1个回答
0
投票

改变线条

jobstores = {
    'redis': RedisJobStore(jobs_key='dispatched_trips_jobs', run_times_key='dispatched_trips_running', host='localhost', port=6379)
}

jobstores = {
    'default': RedisJobStore(jobs_key='dispatched_trips_jobs', run_times_key='dispatched_trips_running', host='localhost', port=6379)
}

工作良好

© www.soinside.com 2019 - 2024. All rights reserved.