Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
time.sleep() crashes Pythonista when used in scene, decorated by @ui.in_background.
-
I know this has been asked before, but I have a different scenario where the solutions suggested won't work. The app crashes when certain functions featuring sleep are run. Pythonista 3.
Here's a sample of code that can sometimes crash the app:
import time import sound vol = 0.1 for _ in range(3): sound.play_effect('rpg:Footstep01', vol) vol += 0.1 time.sleep(1) sound.play_effect('rpg:Footstep02', vol) vol += 0.1 time.sleep(1) sound.play_effect('rpg:Footstep03', vol) vol += 0.1 time.sleep(1)
Any ideas? This function is decorated by
@ui_in_background
as it is called by theupdate
function built into scene.(No, that doesn't mean there are footsteps playing all the time, it's part of an AI I'm working on:p)
-
The main takeaway from that thread... don't use sleep in scene. Use actions.
What you have would work with a Action.sequence consisting of an Action.call (to play the sound), and an Action.wait.
-
I'll give it a try, thanks.