From 03009e5be46776a7f354f439e4a65a6e87dd5725 Mon Sep 17 00:00:00 2001 From: Gennady Kovshenin Date: Thu, 4 Jan 2024 16:25:41 +0300 Subject: [PATCH] Fix `resolve_connection` deprecation #304 The Connection context manager in rq is deprecated. When a connection is explicitly passed to the Scheduler avoid using the manager and triggering a warning. --- rq_scheduler/scheduler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rq_scheduler/scheduler.py b/rq_scheduler/scheduler.py index 8566303..410bc0a 100644 --- a/rq_scheduler/scheduler.py +++ b/rq_scheduler/scheduler.py @@ -30,8 +30,10 @@ class Scheduler(object): def __init__(self, queue_name='default', queue=None, interval=60, connection=None, job_class=None, queue_class=None, name=None): - from rq.connections import resolve_connection - self.connection = resolve_connection(connection) + self.connection = connection + if self.connection is None: + from rq.connections import resolve_connection + self.connection = resolve_connection(connection) self._queue = queue if self._queue is None: self.queue_name = queue_name