fix case when client does not have a name (#2103)

* fix case when client does not have a name

* lint using black
This commit is contained in:
Wei-Chun Kao 2024-07-18 10:45:37 +08:00 committed by GitHub
parent df5e99ba0b
commit 458a2ff228
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -222,7 +222,9 @@ class BaseWorker:
warnings.warn('CLIENT SETNAME command not supported, setting ip_address to unknown', Warning) warnings.warn('CLIENT SETNAME command not supported, setting ip_address to unknown', Warning)
self.ip_address = 'unknown' self.ip_address = 'unknown'
else: else:
client_adresses = [client['addr'] for client in connection.client_list() if client['name'] == self.name] client_adresses = [
client['addr'] for client in connection.client_list() if client.get('name') == self.name
]
if len(client_adresses) > 0: if len(client_adresses) > 0:
self.ip_address = client_adresses[0] self.ip_address = client_adresses[0]
else: else: