I think you can do something like this
start = time.time()
is not a timer.
it just stores the time at the moment this statement is processed into the value start.
So later on all around the place, where you have access to the variable start, you can check the time, that elapsed since start:
elapsed = time.time() - start
So without stepping into subprocessing or even event processing, you need a function that starts a new timer and can be asked, whether a given time has elapsed and a global storage for the timer values.
basic timer function:
def timer(name, elapse=0):
if elapse > 0: # we start a timer
exec("Settings.myTimer" + str(name) + "=time.time()+" + str(elapse)
else # we check the timer
rest = eval("Settings.myTimer" + str(name)) - time.time()
if rest > 0: return False # not yet elapsed
else return True
usage:
timer(1, 100) will start now and elapse in 100 seconds
# ... some code
if timer(1): print "timer1: time is over"
As global storage for the timer values I use the Sikuli Settings class.
Since the timer not really does anything, it is just storing a value for later comparison, you do not need a "reset".
just repeating the above sequence would give a new value to Settings.myTimer1