[gnome-keysign: 43/65] bluetoothreceive: catch exception trying to double close a connection



commit e8521b9b11277565bb77a1aef9c8793af65c4084
Author: RyuzakiKK <aasonykk gmail com>
Date:   Mon Aug 21 12:17:35 2017 +0200

    bluetoothreceive: catch exception trying to double close a connection

 keysign/bluetoothreceive.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/keysign/bluetoothreceive.py b/keysign/bluetoothreceive.py
index b6fa1a2..c365645 100644
--- a/keysign/bluetoothreceive.py
+++ b/keysign/bluetoothreceive.py
@@ -105,8 +105,14 @@ class BluetoothReceive:
     def stop(self):
         self.stopped = True
         if self.client_socket:
-            self.client_socket.shutdown(socket.SHUT_RDWR)
-            self.client_socket.close()
+            try:
+                self.client_socket.shutdown(socket.SHUT_RDWR)
+                self.client_socket.close()
+            except BluetoothError as be:
+                if be.args[0] == "(9, 'Bad file descriptor')":
+                    log.info("The old Bluetooth connection was already closed")
+                else:
+                    log.warning("An unknown bt error occurred: %s" % be.args[0])
 
 
 def main(args):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]