在标准使用情况下,aio.gather() 会引发 RuntimeWarnings
作者: cwag-gh创建于 2025年11月29日更新于 2026年7月9日
在我认为是标准方式(#1174)中使用 aio.gather() :
from browser import aio
async def coro1():
await aio.sleep(0.1)
print('Coro 1')
async def coro2():
await aio.sleep(0.2)
print('Coro 2')
async def main():
await aio.gather(coro1(), coro2())
print('all done')
aio.run(main())在在线编辑器中,我得到以下输出:
VFS._aio.py:14: RuntimeWarning: coroutine 'undefined' was never awaited
return _task()
VFS._aio.py:14: RuntimeWarning: coroutine 'undefined' was never awaited
return _task()
Coro 1
Coro 2
all done我尝试将协程保存为变量以测试是否是作用域问题,但这似乎没有帮助。
内容来源: brython-dev/brython