Ignore Redis errors when a backend sends an unregister notify event.

When that happens, it's most likely that the application is already
stopping and the Redis service has already been terminated.
This commit is contained in:
Fabio Manganiello 2023-08-17 01:49:41 +02:00
parent 3bf068e0b2
commit ec2b8da983
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -441,6 +441,8 @@ class Backend(Thread, EventGenerator, ExtensionWithManifest):
"""
Unregister the Zeroconf service configuration if available.
"""
from redis import exceptions
if self.zeroconf and self.zeroconf_info:
try:
self.zeroconf.unregister_service(self.zeroconf_info)
@ -458,6 +460,7 @@ class Backend(Thread, EventGenerator, ExtensionWithManifest):
except TimeoutError:
pass
try:
if self.zeroconf_info:
self.bus.post(
ZeroconfServiceRemovedEvent(
@ -467,8 +470,12 @@ class Backend(Thread, EventGenerator, ExtensionWithManifest):
)
else:
self.bus.post(
ZeroconfServiceRemovedEvent(service_type=None, service_name=None)
ZeroconfServiceRemovedEvent(
service_type=None, service_name=None
)
)
except exceptions.ConnectionError:
pass
self.zeroconf_info = None
self.zeroconf = None