From 77e7ef6983871175a51bd10f340c6020765e2a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Ferradas?= Date: Thu, 15 Jul 2021 03:09:25 +0100 Subject: [PATCH] Handle ResponseError when CLIENT command is not supported (#1514) * catch redis ResponseError if CLIENT command not supported * use Warning instead of UserWarning --- rq/worker.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rq/worker.py b/rq/worker.py index ff63ab1..8176795 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -221,8 +221,16 @@ class Worker: if prepare_for_work: self.hostname = socket.gethostname() self.pid = os.getpid() - connection.client_setname(self.name) - self.ip_address = [client['addr'] for client in connection.client_list() if client['name'] == self.name][0] + try: + connection.client_setname(self.name) + except redis.exceptions.ResponseError: + warnings.warn( + 'CLIENT command not supported, setting ip_address to unknown', + Warning + ) + self.ip_address = 'unknown' + else: + self.ip_address = [client['addr'] for client in connection.client_list() if client['name'] == self.name][0] else: self.hostname = None self.pid = None