multithreading - Using timer object in python to call a function after certain invertal -


i have used following technique call function after interval. problem is being called twice @ interval of 5 seconds. after every 5 seconds function being called twice. how resolve this? code part of class.

self.t=timer(5,self.checktimeout)    self.t.start() def checktimeout(self):      print("game over")      timer(5,self.checktimeout).start() 

this timer wrote while ago. try out this. me works perfectly!

def countdown(t): while t:     mins, secs = divmod(t, 60)     #print timeformat     #timeformat = '\r{:02d}:{:02d}'.format(mins, secs)     #sys.stdout.write(timeformat)     #sys.stdout.flush()     time.sleep(1)     t -= 1 

call this:

def main():     minutes = 1     cnttime = minutes * 60     while(true):         countdown(cnttime)         yourfunction() 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -