[module/publicip] handle netifaces errors

make sure the monitoring thread doesn't terminate when there are
netifaces errors.

see #909
This commit is contained in:
tobi-wan-kenobi 2022-08-06 09:17:49 +02:00
parent a7dba79664
commit 7a47e9e13d

View file

@ -60,8 +60,13 @@ class Module(core.module.Module):
current_default_route = None current_default_route = None
default_route = None default_route = None
while threading.main_thread().is_alive(): while threading.main_thread().is_alive():
try:
current_default_route = netifaces.gateways()["default"][2] 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: if current_default_route != default_route:
default_route = current_default_route
self.update() self.update()
time.sleep(1) time.sleep(1)