Handle ResponseError when CLIENT command is not supported (#1514)

* catch redis ResponseError if CLIENT command not supported

* use Warning instead of UserWarning
main
César Ferradas 3 years ago committed by GitHub
parent 653d4917e7
commit 77e7ef6983
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -221,7 +221,15 @@ class Worker:
if prepare_for_work: if prepare_for_work:
self.hostname = socket.gethostname() self.hostname = socket.gethostname()
self.pid = os.getpid() self.pid = os.getpid()
try:
connection.client_setname(self.name) 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] self.ip_address = [client['addr'] for client in connection.client_list() if client['name'] == self.name][0]
else: else:
self.hostname = None self.hostname = None

Loading…
Cancel
Save