Skip to content

Instantly share code, notes, and snippets.

@stamat
Created April 12, 2013 10:50
Show Gist options
  • Save stamat/5371218 to your computer and use it in GitHub Desktop.
Save stamat/5371218 to your computer and use it in GitHub Desktop.
Python setInterval() equivalent
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
@anchikhorov
Copy link

this not will work as expected, it python no such analog

@craigbarrington
Copy link

craigbarrington commented Aug 8, 2024

Just make a function in an infinite loop:

def one_second_interval():
.....print("x")
.....time.sleep(1)

while True:
.....one_second_interval()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment