From f0b90f9bedf5edb2a22dab4742ce2addd504e259 Mon Sep 17 00:00:00 2001 From: Peter Ujvari Date: Fri, 7 Apr 2017 11:10:08 +0200 Subject: [PATCH 1/2] alterable scheduler keys --- rq_scheduler/scheduler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rq_scheduler/scheduler.py b/rq_scheduler/scheduler.py index 78bab4e..bee5dac 100644 --- a/rq_scheduler/scheduler.py +++ b/rq_scheduler/scheduler.py @@ -17,10 +17,8 @@ class Scheduler(object): - scheduler_key = 'rq:scheduler' - scheduled_jobs_key = 'rq:scheduler:scheduled_jobs' - def __init__(self, queue_name='default', interval=60, connection=None): + def __init__(self, queue_name='default', interval=60, connection=None, scheduler_key=None, scheduled_jobs_key=None): from rq.connections import resolve_connection self.connection = resolve_connection(connection) self.queue_name = queue_name @@ -28,6 +26,9 @@ def __init__(self, queue_name='default', interval=60, connection=None): self.log = logger self._lock_acquired = False + self.scheduler_key = scheduler_key or 'rq:scheduler' + self.scheduled_jobs_key = scheduled_jobs_key or 'rq:scheduler:scheduled_jobs' + def register_birth(self): if self.connection.exists(self.scheduler_key) and \ not self.connection.hexists(self.scheduler_key, 'death'): From 76a3df7ee77a77cb52a53fe6bf390ad006c64f74 Mon Sep 17 00:00:00 2001 From: Peter Ujvari Date: Fri, 7 Apr 2017 11:34:00 +0200 Subject: [PATCH 2/2] alterable scheduler keys fix --- rq_scheduler/scheduler.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rq_scheduler/scheduler.py b/rq_scheduler/scheduler.py index bee5dac..eee030a 100644 --- a/rq_scheduler/scheduler.py +++ b/rq_scheduler/scheduler.py @@ -17,6 +17,8 @@ class Scheduler(object): + scheduler_key = 'rq:scheduler' + scheduled_jobs_key = 'rq:scheduler:scheduled_jobs' def __init__(self, queue_name='default', interval=60, connection=None, scheduler_key=None, scheduled_jobs_key=None): from rq.connections import resolve_connection @@ -26,8 +28,11 @@ def __init__(self, queue_name='default', interval=60, connection=None, scheduler self.log = logger self._lock_acquired = False - self.scheduler_key = scheduler_key or 'rq:scheduler' - self.scheduled_jobs_key = scheduled_jobs_key or 'rq:scheduler:scheduled_jobs' + if scheduler_key: + self.scheduler_key = scheduler_key + + if scheduled_jobs_key: + self.scheduled_jobs_key = scheduled_jobs_key def register_birth(self): if self.connection.exists(self.scheduler_key) and \