Timer object callbacks aren't executed asynchronously
In the example below, the function "a" is not being called asynchronously. The UI thread is blocked during each call to time.sleep and a spinner cursor is shown for 20 seconds.
I may just be misunderstanding how Timer objects are supposed to work. If that's the case, can you let me know if rumps includes a way to execute Timer callbacks (the "a" function in this case) in a separate thread?
import rumps
import time
def a(_):
print "blah"
time.sleep(20)
if __name__ == "__main__":
app = rumps.App('TestApp', menu=('Fake', 'All timers', 'Start timer', 'Stop timer'))
global_namespace_timer = rumps.Timer(a, 30)
global_namespace_timer.start()
app.run()
I think this is a bug. From what I've read in the documentation for the Timer class:
Python abstraction of an Objective-C event timer in a new thread for application.
http://rumps.readthedocs.org/en/latest/Timer.html
A possible workaround is to use python's Timer class in the threading module.
Is it resolved? I am still facing this issue.
@dalleng can you give an example on how I can use time with threading to make it run async? The timer stops working when I have the app menu open.