asynchronous - 如何检查 Python 中没有等待就调用的异步函数?
问题描述
假设我们有以下功能:
async def x1():
print("inside x1")
async def x2():
print("inside x2")
async def main():
await x1()
x2()
await asyncio.sleep(5)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
我将收到以下警告:
RuntimeWarning: coroutine 'x2' was never awaited
有什么方法可以让 Python 引发错误而不仅仅是打印警告?
解决方案
推荐阅读
- python - 配准具有不同视野的非各向同性 CT 扫描
- python - 在python中定义数组时出现语法错误
- excel - 遍历所有行并找到活动工作表 VBA 的空行
- bootstrap-4 - 使用行/容器引导程序填充窗口剩余高度
- python - 如何在运行 selenium 时在 mac 上粘贴剪贴板中的文本 - Python
- java - 从 (RSA) PublicKey 手动创建 JWK
- azure - 从门户更改 Azure Api 管理中的服务结构终结点端口
- python - python误读文件路径名
- html - 真正的 HTML 跨浏览器难题?
- server - 如何通过 WHM 将子域转移到其他子域