summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaZderMind <peter@mazdermind.de>2014-09-03 20:43:04 +0200
committerMaZderMind <peter@mazdermind.de>2014-09-03 20:43:04 +0200
commitf59b1f19172bb7e5187f91fd37a89d7cc9217795 (patch)
tree4b5c2cb31c57a0d0f23c0ea7f4c709336aa9850c
parentbf9dc34408bdbb75e710e13167cfbf354e4c086e (diff)
better timeout mechanism
-rw-r--r--voctocore/lib/shmsrc.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/voctocore/lib/shmsrc.py b/voctocore/lib/shmsrc.py
index 0224386..76b95e8 100644
--- a/voctocore/lib/shmsrc.py
+++ b/voctocore/lib/shmsrc.py
@@ -7,6 +7,7 @@ from lib.config import Config
class FailsafeShmSrc(Gst.Bin):
log = logging.getLogger('FailsafeShmSrc')
last_buffer_arrived = 0
+ last_restart_retry = 0
is_in_failstate = True
def __init__(self, socket):
@@ -55,7 +56,7 @@ class FailsafeShmSrc(Gst.Bin):
self.shmsrc.get_static_pad('src').add_probe(Gst.PadProbeType.BLOCK | Gst.PadProbeType.BUFFER, self.data_probe, None)
# Install Watchdog
- GLib.timeout_add(500, self.watchdog)
+ GLib.timeout_add(250, self.watchdog)
# Add Ghost Pads
self.add_pad(
@@ -86,11 +87,13 @@ class FailsafeShmSrc(Gst.Bin):
return Gst.PadProbeReturn.PASS
def watchdog(self):
- if self.last_buffer_arrived + 0.1 < time.time():
+ t = time.time()
+ if self.last_buffer_arrived + 0.1 < t:
self.log.warning('watchdog encountered a timeout')
self.switch_to_failstate()
- if self.last_buffer_arrived + 3 < time.time() and round(time.time() % 3) == 0:
+ if self.is_in_failstate and self.last_restart_retry + 1 < t:
+ self.last_restart_retry = t
self.restart()
return True