From 56e756f512979b0151b539c9473ceadb01afbabf Mon Sep 17 00:00:00 2001 From: Sergei Zherevchuk Date: Thu, 27 Aug 2020 07:30:46 +0300 Subject: [PATCH] fix(scheduler): correctly restore ssl connection after forking (#1327) * fix(scheduler): restore ssl connection after forking * fix(scheduler): custom redis client support --- rq/scheduler.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rq/scheduler.py b/rq/scheduler.py index 17e2c5d..b55f728 100644 --- a/rq/scheduler.py +++ b/rq/scheduler.py @@ -13,8 +13,7 @@ from .registry import ScheduledJobRegistry from .utils import current_timestamp, enum from .logutils import setup_loghandlers -from redis import Redis - +from redis import Redis, SSLConnection SCHEDULER_KEY_TEMPLATE = 'rq:scheduler:%s' SCHEDULER_LOCKING_KEY_TEMPLATE = 'rq:scheduler-lock:%s' @@ -47,6 +46,10 @@ class RQScheduler(object): self._scheduled_job_registries = [] self.lock_acquisition_time = None self._connection_kwargs = connection.connection_pool.connection_kwargs + self._connection_class = connection.__class__ # client + connection_class = connection.connection_pool.connection_class + if issubclass(connection_class, SSLConnection): + self._connection_kwargs['ssl'] = True self._connection = None self.interval = interval self._stop_requested = False @@ -57,8 +60,8 @@ class RQScheduler(object): def connection(self): if self._connection: return self._connection - self._connection = Redis(**self._connection_kwargs) - return Redis(**self._connection_kwargs) + self._connection = self._connection_class(**self._connection_kwargs) + return self._connection @property def acquired_locks(self):