fix(scheduler): correctly restore ssl connection after forking (#1327)

* fix(scheduler): restore ssl connection after forking

* fix(scheduler): custom redis client support
main
Sergei Zherevchuk 4 years ago committed by GitHub
parent 08379fc571
commit 56e756f512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,8 +13,7 @@ from .registry import ScheduledJobRegistry
from .utils import current_timestamp, enum from .utils import current_timestamp, enum
from .logutils import setup_loghandlers from .logutils import setup_loghandlers
from redis import Redis from redis import Redis, SSLConnection
SCHEDULER_KEY_TEMPLATE = 'rq:scheduler:%s' SCHEDULER_KEY_TEMPLATE = 'rq:scheduler:%s'
SCHEDULER_LOCKING_KEY_TEMPLATE = 'rq:scheduler-lock:%s' SCHEDULER_LOCKING_KEY_TEMPLATE = 'rq:scheduler-lock:%s'
@ -47,6 +46,10 @@ class RQScheduler(object):
self._scheduled_job_registries = [] self._scheduled_job_registries = []
self.lock_acquisition_time = None self.lock_acquisition_time = None
self._connection_kwargs = connection.connection_pool.connection_kwargs 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._connection = None
self.interval = interval self.interval = interval
self._stop_requested = False self._stop_requested = False
@ -57,8 +60,8 @@ class RQScheduler(object):
def connection(self): def connection(self):
if self._connection: if self._connection:
return self._connection return self._connection
self._connection = Redis(**self._connection_kwargs) self._connection = self._connection_class(**self._connection_kwargs)
return Redis(**self._connection_kwargs) return self._connection
@property @property
def acquired_locks(self): def acquired_locks(self):

Loading…
Cancel
Save