From 153d29cce74cf1143a5f6bbe2672e7fb55b9abfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Y=C4=B1lmaz?= <46003469+yilmaz-burak@users.noreply.github.com> Date: Sun, 21 Aug 2022 09:50:00 +0300 Subject: [PATCH] fix listindex error (#1700) --- rq/worker.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/rq/worker.py b/rq/worker.py index 1e2ea4a..f996e6b 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -219,16 +219,24 @@ class Worker: connection.client_setname(self.name) except redis.exceptions.ResponseError: warnings.warn( - 'CLIENT command not supported, setting ip_address to unknown', + 'CLIENT SETNAME command not supported, setting ip_address to unknown', Warning ) self.ip_address = 'unknown' else: - self.ip_address = [ + client_adresses = [ client['addr'] for client in connection.client_list() if client['name'] == self.name - ][0] + ] + if len(client_adresses) > 0: + self.ip_address = client_adresses[0] + else: + warnings.warn( + 'CLIENT LIST command not supported, setting ip_address to unknown', + Warning + ) + self.ip_address = 'unknown' else: self.hostname = None self.pid = None