From 12096f2dbe8b97c9a283358e8254d478bf90d2fb Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 19 Mar 2023 12:56:53 +0100 Subject: [PATCH] Don't fail hard when device disconnection fails. --- platypush/plugins/bluetooth/_legacy/_manager/_base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/bluetooth/_legacy/_manager/_base.py b/platypush/plugins/bluetooth/_legacy/_manager/_base.py index 8672fbac..8f8b5b3a 100644 --- a/platypush/plugins/bluetooth/_legacy/_manager/_base.py +++ b/platypush/plugins/bluetooth/_legacy/_manager/_base.py @@ -180,7 +180,13 @@ class LegacyManager(BaseBluetoothManager): # Close the connection once the context is over with self._connection_locks[conn.key]: - conn.close() + try: + conn.close() + except Exception as e: + self.logger.warning( + 'Error while closing the connection to %s: %s', device, e + ) + self._connections.pop(conn.key, None) dev.connected = False