From 7a47e9e13dee1913dd4ae3bcaeefcc5f03acde3c Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sat, 6 Aug 2022 09:17:49 +0200 Subject: [PATCH] [module/publicip] handle netifaces errors make sure the monitoring thread doesn't terminate when there are netifaces errors. see #909 --- bumblebee_status/modules/contrib/publicip.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bumblebee_status/modules/contrib/publicip.py b/bumblebee_status/modules/contrib/publicip.py index a187cba..86a21d7 100644 --- a/bumblebee_status/modules/contrib/publicip.py +++ b/bumblebee_status/modules/contrib/publicip.py @@ -60,8 +60,13 @@ class Module(core.module.Module): current_default_route = None default_route = None while threading.main_thread().is_alive(): - current_default_route = netifaces.gateways()["default"][2] + try: + current_default_route = netifaces.gateways()["default"][2] + except: + # error reading out default gw -> assume none exists + current_default_route = None if current_default_route != default_route: + default_route = current_default_route self.update() time.sleep(1)