Created
April 12, 2013 10:50
-
-
Save stamat/5371218 to your computer and use it in GitHub Desktop.
Python setInterval() equivalent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
def set_interval(func, sec): | |
def func_wrapper(): | |
set_interval(func, sec) | |
func() | |
t = threading.Timer(sec, func_wrapper) | |
t.start() | |
return t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just make a function in an infinite loop:
def one_second_interval():
.....print("x")
.....time.sleep(1)
while True:
.....one_second_interval()