DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Using Ao_timer For A Better Sleep
A few of my old examples include 'unsafe' use of e32.ao_sleep(). The problem is that the sleep can't be interrupted. I often use a convenient loop like this
while running: // do something e32.ao_sleep(1) # sleep a sec
Now in pys60 1.3.1, it's better to use e32.Ao_timer
timer = e32.Ao_timer() while running: // do something timer.after(1) # sleep a sec
I can then interupt the sleep with
in other part of the program if I need to continue the loop. For example, I can end the application without waiting for the last second.