C
C
CodeOrNotCode2022-01-17 21:02:52
Python
CodeOrNotCode, 2022-01-17 21:02:52

How to make a delay for a single function and not for the entire code in Python?

The other day I was making a voice assistant in Python and there was a need for the races to turn on the function after a certain time. I wanted to do it through an ordinary sleep (), but unfortunately sleep () suspends the entire program. And now I want to know whether it is possible to implement what I wanted or not in regular Python. Maybe there are some libraries?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2022-01-17
@CodeOrNotCode

Depends on the implementation of the helper.
If you use the asynchronous approach, then asyncio.sleep().
If you use synchronous code, then run a separate thread (if it works).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question