From f07fb205a5d0c0c2b4066eb21ddecc26e84f3bde Mon Sep 17 00:00:00 2001 From: Arthur Golubtsov Date: Tue, 17 Dec 2019 08:57:01 +0000 Subject: [PATCH] Client: Add try/except dummy for getting map --- Drone/client.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Drone/client.py b/Drone/client.py index 5d37e16..f004e2d 100644 --- a/Drone/client.py +++ b/Drone/client.py @@ -216,13 +216,15 @@ class Client(object): if isinstance(error, OSError): if error.errno == errno.EINTR: raise KeyboardInterrupt - - mapping = self.selector.get_map().values() - notifier_key = self.selector.get_key(messaging.NotifierSock().get_sock()) - notify_only= len(mapping) == 1 and notifier_key in mapping - if notify_only or not mapping: - logger.warning("No active connections left!") - return + try: + mapping = self.selector.get_map().values() + notifier_key = self.selector.get_key(messaging.NotifierSock().get_sock()) + notify_only= len(mapping) == 1 and notifier_key in mapping + if notify_only or not mapping: + logger.warning("No active connections left!") + return + except (RuntimeError, KeyError) as e: + logger.error("Exception {} occured when getting net map!".format(e)) @messaging.message_callback("config_write")