Search code examples
python-3.xredisapscheduler

python apschedular RedisJobStore not storing jobs in redis cache


That is my python code: All jobs are triggering at right time but not stored as redis cache. If restart the program, cannot schedule pending jobs. What I am doing wrong?

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

Solution

  • Changing the lines

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

    to

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

    works fine