Last active
December 14, 2016 21:29
-
-
Save crawles/6dc7e154cf1e8a49554faac440e097e2 to your computer and use it in GitHub Desktop.
Async set_interval function
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 | |
# 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