1

I was learning about time module in python and I wanted to make a delay in my function like setInterval and clearInterval. I was trying to make something with time module but I cant run my code correctly.

I just want to make a simple setInterval and clearInteval and setTimeout with a simple code.

from threading import Timer
import time
run = True
def test():
    global run
    print("something")
    if run:
        Timer(1, test).start()
        time.sleep(2)

test()
Nick ODell
  • 15,465
  • 3
  • 32
  • 66
manipapan2
  • 11
  • 2

0 Answers0