fix listindex error (#1700)

This commit is contained in:
Burak Yılmaz 2022-08-21 09:50:00 +03:00 committed by GitHub
parent 8e3283dab3
commit 153d29cce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -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