N
N
NOblo2020-06-08 16:57:08
Python
NOblo, 2020-06-08 16:57:08

How to delay a program?

I want to make the program wait, without time.sleep() <--- it stops the program, but I want it to wait for something, which module should I use?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
megared, 2020-06-08
@NOblo

Try using the threading module and its Timer:
Click.

from threading import Timer

def hello():
    print "hello, world"

t = Timer(30.0, hello)
t.start()  # через 30 секунд выведется "hello, world".

S
Sergey Gornostaev, 2020-06-08
@sergey-gornostaev

A module that is waiting for something.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question