anoop-khandelwal
anoop-khandelwal

Reputation: 3860

Does Disque have a feature like RedisJobStore in redis?

I wanted to use disque as a job-store. I implemented the same with redis using RedisJobStore Class in Apscheduler.

Here is the snippet with redis job-store:

    from apscheduler.jobstores.redis import RedisJobStore
    job_stores = {
                  'default': RedisJobStore(jobs_key='ap_scheduler.jobs', run_times_key='ap_scheduler.run_times')
    }

Is it possible to create a wrapper using RedisJobStore class to create job store in disque which can then be use by apscheduler?

  class RedisJobStore(BaseJobStore):
      def __init__(self, db=0, jobs_key='apscheduler.jobs', run_times_key='apscheduler.run_times',
             pickle_protocol=pickle.HIGHEST_PROTOCOL, **connect_args):
    super(RedisJobStore, self).__init__()
    c = Client(['localhost:7711'])
    self.disque = c.connect()

    def lookup_job(self, job_id):
        job_state = self.disque.hget(self.jobs_key, job_id)
        return self._reconstitute_job(job_state) if job_state else 
               None

Upvotes: 1

Views: 307

Answers (0)

Related Questions