omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.

    Pythonista
    time game scene
    2
    3
    3985
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • lachlantula
      lachlantula last edited by lachlantula

      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 the update 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)

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by JonB

        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.

        1 Reply Last reply Reply Quote 1
        • lachlantula
          lachlantula last edited by

          I'll give it a try, thanks.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors