]>
git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - helpers/actions/wait.py
3 def run(action
, duration
=0, music
=None, set_wait_id
=None, **kwargs
):
4 if set_wait_id
is not None:
5 action
.mapping
.add_wait_id(set_wait_id
, action
)
7 action
.sleep_event
= threading
.Event()
8 action
.sleep_event_timer
= threading
.Timer(
10 action
.sleep_event
.set)
15 action
.sleep_event_timer
.start()
16 action
.sleep_event
.wait()
18 def description(action
, duration
=0, music
=None, set_wait_id
=None, **kwargs
):
21 message
+= "waiting {}s" \
24 message
+= "waiting the end of « {} »" \
27 message
+= "waiting the end of « {} » + {}s" \
28 .format(music
.name
, duration
)
30 if set_wait_id
is not None:
31 message
+= " (setting id = {})".format(set_wait_id
)
35 def interrupt(action
, duration
=0, music
=None, **kwargs
):
36 if action
.sleep_event
is not None:
37 action
.sleep_event
.set()
38 action
.sleep_event_timer
.cancel()
40 music
.wait_event
.set()