redis_uri = config.LOCAL_REDIS_URI or config.REDIS_URI connection_pool = ConnectionPool.from_url(redis_uri) job_store = RedisJobStore(connection_pool=connection_pool) job_stores = {'default': job_store} scheduler = BlockingScheduler(timezOne='Asia/Shanghai', jobstores=job_stores) def check_new_job(): print(scheduler.get_jobs()) with open('text.txt', 'a+') as f: f.write(f'{time.time()}\n') def run(): scheduler.add_job(check_new_job, 'interval', secOnds=5, id='job_test2', next_run_time=datetime.now(), replace_existing=True) scheduler.start()
- 如果用默认的 MemoryJobStore 打印跟写入的时间戳都正常
- 用 RedisJobStore 没有打印,文件写没有写入时间戳,redis 是正常的,可以看到 job 写到 redis 了
- 第一次运用会有打印跟写入,5 秒后的下一次运行就没有打印与写入
- 关掉程序,在运行同样没有打印与写入
- RedisJobStore 为什么没有打印?