采用 asyncio 开发

异步编程不同于经典的 "顺序" 编程。

此页面列出了常见过失和陷阱,并解释了如何避免它们。

调试模式

默认情况下,asyncio 在生产模式下运行。为易于开发,asyncio 有 调试模式 .

有几种方式能启用 asyncio 调试模式:

In addition to enabling the debug mode, consider also:

  • setting the log level of the asyncio logger to logging.DEBUG , for example the following snippet of code can be run at startup of the application:

    logging.basicConfig(level=logging.DEBUG)