asyncio --- 异步 I/O¶


asyncio 是用�编写 并� 代�的库,使用 async/await 语法。

asyncio 被用作多个�供高性能 Python 异步框架的基础,包括网络和网站�务,数�库连接库,分布�任务队列等等。

asyncio 往往是构建 IO 密集型和高层级 结构化 网络代�的最佳选择。

asyncio �供一组 高层级 API 用于:

此外,还有一些 低层级 API 以支� 库和框架的开�者 实现:

你�以在 REPL 中�试使用 asyncio 并�上下文:

$ python -m asyncio
asyncio REPL ...
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> await asyncio.sleep(10, result='hello')
'hello'

�用性: � Emscripten,� WASI。

此模�在 WebAssembly 平� wasm32-emscripten 和 wasm32-wasi 上�适用或��用。 请�阅 WebAssembly 平� 了解详情。

�考

备注

asyncio 的�代��以在 Lib/asyncio/ 中找到。