diff --git a/rq/worker.py b/rq/worker.py index 1e2ea4af..f996e6b3 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