]>
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(duration
, action
.sleep_event
.set)
13 action
.sleep_event_timer
.start()
14 action
.sleep_event
.wait()
16 def description(action
, duration
=0, music
=None, set_wait_id
=None, **kwargs
):
19 message
+= "waiting {}s" \
22 message
+= "waiting the end of « {} »" \
25 message
+= "waiting the end of « {} » + {}s" \
26 .format(music
.name
, duration
)
28 if set_wait_id
is not None:
29 message
+= " (setting id = {})".format(set_wait_id
)
33 def interrupt(action
, duration
=0, music
=None, **kwargs
):
34 if action
.sleep_event
is not None:
35 action
.sleep_event
.set()
36 action
.sleep_event_timer
.cancel()
38 music
.wait_event
.set()