]>
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 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
):
22 message
+= "waiting {}s"
23 formats
.append(duration
)
25 message
+= "waiting the end of « {} »"
26 formats
.append(music
.name
)
28 message
+= "waiting the end of « {} » + {}s"
29 formats
.append(music
.name
)
30 formats
.append(duration
)
32 if set_wait_id
is not None:
33 message
+= " (setting id = {})"
34 formats
.append(set_wait_id
)
36 return _(message
).format(*formats
)
38 def interrupt(action
, duration
=0, music
=None, **kwargs
):
39 if action
.sleep_event
is not None:
40 action
.sleep_event
.set()
41 action
.sleep_event_timer
.cancel()
43 music
.wait_event
.set()