Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to run a function in interval in python

# This runs test() function in intervals of 1 second
from threading import Timer
run = True
def test():
	global run
	print("something")
	if run:
		Timer(1, test).start()

test()
# now whenever you set run to False the test function won't run anymore
# and of course if you dont set it to False it will run forever
 
PREVIOUS NEXT
Tagged: #run #function #interval #python
ADD COMMENT
Topic
Name
5+3 =