Commit e67d2bf2 authored by David Trattnig's avatar David Trattnig
Browse files

Parent:child dependency using join(). #62

parent 019f014d
......@@ -248,14 +248,19 @@ class EngineExecutor(Timer):
def on_ready(self, func):
Calls the passed function `func` when the timer is ready.
def wait_for_parent(self):
Child timers are dependend on their parents. So let's wait until parents are done with their stuff.
if self.parent_timer:
# Wait a bit to allow any parent to complete initialization, in case child & parent are instantiated at the 'same' time
# Required to avoid "Thread.__init__() not called" exceptions on the parent
while self.parent_timer.is_alive():"Timer '{self.timer_id}' is waiting for parent timer '{self.parent_timer.timer_id}' to finish")
......@@ -471,9 +471,9 @@ class PlayCommand(EngineExecutor):
start_preload = entries[0].start_unix - self.config.get("preload_offset")
start_play = entries[0].start_unix
super().__init__("PLAY", None, start_preload, self.do_preload, entries)
EngineExecutor("PLAY", self, start_play, self.do_play, entries)
preload_timer = super().__init__("PLAY", None, start_preload, self.do_preload, entries)
self.on_ready(lambda: EngineExecutor("PLAY", self, start_play, self.do_play, entries))
def do_preload(self, entries):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment