Skip to content

Instantly share code, notes, and snippets.

@crawles
Last active December 14, 2016 21:29
Show Gist options
  • Save crawles/6dc7e154cf1e8a49554faac440e097e2 to your computer and use it in GitHub Desktop.
Save crawles/6dc7e154cf1e8a49554faac440e097e2 to your computer and use it in GitHub Desktop.
Async set_interval function
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
# example
a = 1
def inc_a():
global a
a += 1
set_interval(inc_a,1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment