asyncio is a library to write concurrent code using the async/await syntax.
asyncio is used as a foundation for multiple Python asynchronous frameworks that provide high-performance network and web-servers, database connection libraries, distributed task queues, etc.
asyncio is often a perfect fit for IO-bound and high-level structured network code.
Create a new task from the given protocol and schedule it to run.
Params
core: Coroutine object
Return value: Task object
Create a new task from the given coroutine and run it until it is completed.
Params
coro: Coroutine object
Return value: the value of coro returns.
Sleep for t seconds (can be a floating-point number). This is a Coroutine.
Sleep for t milliseconds. This is a Coroutine.
Wait for
awaitableto complete, but if it requires a longer timeout seconds, please cancel it. If awaitable is not a task, then a task will be created from it.If a timeout occurs, it will cancel the task and trigger
asyncio.TimeoutError: This should be captured by the caller.This is a Coroutine.
Params:
awaitable:awaitable object.timeout:timeout seconds
Return value:the value of awaitable returns.
like
wait_forbut the timeout unit is milliseconds.This is a Coroutine.
Params:
awaitable:awaitable object.timeout:timeout milliseconds
Return value:the value of awaitable returns.
Run all waits simultaneously. Any waiting item that is not a task is elevated to a task.
This is a Coroutine.
Params:
awaitable:awaitable object.return_exceptions: if the exception object returned flag.
Return value:the value of awaitable returns.
Create a new event that can be used to synchronize tasks. The event starts with a clear state.
Truereturns if an event is set, otherwiseFalsereturns.
Set events. Any task waiting for an event will be scheduled to run.
clear event.
Wait for the event to be set. If the event has already been set, it will immediately return.
This is a Coroutine.