]>
git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - music_sampler/actions/wait.py
3 def run(action
, duration
=0, music
=None, set_wait_id
=None, **kwargs
):
4 action
.mapping
.add_wait(action
, wait_id
=set_wait_id
)
6 action
.sleep_event
= threading
.Event()
7 action
.sleep_event_timer
= threading
.Timer(
9 action
.sleep_event
.set)
14 action
.sleep_event_timer
.start()
15 action
.sleep_event
.wait()
17 def description(action
, duration
=0, music
=None, set_wait_id
=None, **kwargs
):
21 message
+= "waiting {}s"
22 formats
.append(duration
)
24 message
+= "waiting the end of « {} »"
25 formats
.append(music
.name
)
27 message
+= "waiting the end of « {} » + {}s"
28 formats
.append(music
.name
)
29 formats
.append(duration
)
31 if set_wait_id
is not None:
32 message
+= " (setting id = {})"
33 formats
.append(set_wait_id
)
35 return _(message
).format(*formats
)
37 def interrupt(action
, duration
=0, music
=None, **kwargs
):
38 if action
.sleep_event
is not None:
39 action
.sleep_event
.set()
40 action
.sleep_event_timer
.cancel()
42 music
.wait_event
.set()