[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
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)