Skip to content

Instantly share code, notes, and snippets.

@TheBits
Created April 7, 2014 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheBits/10020584 to your computer and use it in GitHub Desktop.
Save TheBits/10020584 to your computer and use it in GitHub Desktop.
Periodic call
import threading
import time
class Ti(threading.Thread):
def __init__(self):
print('inittt')
self.k = 1
self.t = None
super().__init__()
def check(self):
print('check%s' % self.k)
self.k += 1
self.t = threading.Timer(1, self.check)
self.t.start()
def run(self):
self.check()
t = Ti()
t.start()
time.sleep(5)
t.t.cancel()
t.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment