[modules/ping] Allow recovery from unreachable

Due to a bug, when the destination was unreachable, the checking thread
would terminate, effectively keeping the widget stuck in "unreachable"
mode.

Now, enable recovery by keeping the thread running even if the target is
not reachable for some time.
This commit is contained in:
Tobi-wan Kenobi 2016-11-18 19:47:28 +01:00
parent d37068b442
commit 0c9177cb79

View file

@ -41,10 +41,6 @@ def get_rtt(obj):
res = subprocess.check_output(shlex.split("ping -n -q -c {} -W {} {}".format( res = subprocess.check_output(shlex.split("ping -n -q -c {} -W {} {}".format(
obj.get("rtt-probes"), obj.get("rtt-timeout"), obj.get("address") obj.get("rtt-probes"), obj.get("rtt-timeout"), obj.get("address")
))) )))
except Exception as e:
obj.set("rtt-unreachable", True)
break
obj.set("rtt-unreachable", False) obj.set("rtt-unreachable", False)
for line in res.decode().split("\n"): for line in res.decode().split("\n"):
@ -55,6 +51,9 @@ def get_rtt(obj):
obj.set("rtt-avg", float(m.group(2))) obj.set("rtt-avg", float(m.group(2)))
obj.set("rtt-max", float(m.group(3))) obj.set("rtt-max", float(m.group(3)))
obj.set("rtt-unit", m.group(5)) obj.set("rtt-unit", m.group(5))
except Exception as e:
obj.set("rtt-unreachable", True)
class Module(bumblebee.module.Module): class Module(bumblebee.module.Module):
def __init__(self, output, config, alias): def __init__(self, output, config, alias):