From ec2b8da9839bd5e63299595642d0b4c6b982e119 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 17 Aug 2023 01:49:41 +0200 Subject: [PATCH] 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. --- platypush/backend/__init__.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/platypush/backend/__init__.py b/platypush/backend/__init__.py index c8b0ea65d6..4835e15434 100644 --- a/platypush/backend/__init__.py +++ b/platypush/backend/__init__.py @@ -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,17 +460,22 @@ class Backend(Thread, EventGenerator, ExtensionWithManifest): except TimeoutError: pass - if self.zeroconf_info: - self.bus.post( - ZeroconfServiceRemovedEvent( - service_type=self.zeroconf_info.type, - service_name=self.zeroconf_info.name, + try: + if self.zeroconf_info: + self.bus.post( + ZeroconfServiceRemovedEvent( + service_type=self.zeroconf_info.type, + service_name=self.zeroconf_info.name, + ) ) - ) - else: - self.bus.post( - ZeroconfServiceRemovedEvent(service_type=None, service_name=None) - ) + else: + self.bus.post( + ZeroconfServiceRemovedEvent( + service_type=None, service_name=None + ) + ) + except exceptions.ConnectionError: + pass self.zeroconf_info = None self.zeroconf = None