In c# we can do something like task.delay(t), stoping the execution of the current thread without blocking it, and allowing that thread to do other stuff until pass time t. So, my question is: what is the way to do this in python?
Asked
Active
Viewed 211 times
0
-
`time.sleep(t)` – mad_ Oct 31 '19 at 14:36
-
Does this answer your question? [time.sleep -- sleeps thread or process?](https://stackoverflow.com/questions/92928/time-sleep-sleeps-thread-or-process) – r.ook Oct 31 '19 at 14:36
1 Answers
1
the async "awaitable" sleep func is asyncio.sleep()
(see the example provided there).
(as opposed to time.sleep
which is just a regular sleep like C#'s Thread.Sleep...)

Adam.Er8
- 12,675
- 3
- 26
- 38
-
Delay in C: delay function is used to suspend execution of a program for a particular time. The op wants to **stop** the execution of the program – Barb Oct 31 '19 at 14:44
-
2@Barb in C# Task.Delay is awaitable, hence OPs request for "stopping execution without blocking it". The equivalent of which in python is exactly asyncio.sleep. – Adam.Er8 Oct 31 '19 at 15:04