提问人:finlytics-hub 提问时间:11/16/2023 更新时间:11/16/2023 访问量:26
Windows 的 Asyncio 问题
Asyncio issue with Windows
问:
使用异步函数运行简单的 python 脚本会在任何后续语句中出现此错误: 在 Windows 上使用 python 3.11.6。不过,该代码在 Linux 和 MacOS 上运行良好。print()
OSError: [WinError 6] The handle is invalid
完整代码:
import ezkl
import asyncio
async def f():
res = await ezkl.calibrate_settings("input.json", "model_4.onnx", "settings.json", "resources")
asyncio.run(f())
print("test")
尝试使用并尝试使用下面修改的代码,但没有任何运气 - 仍然收到相同的错误。nest_asyncio.apply()
OSError: [WinError 6] The handle is invalid
import ezkl
import asyncio
async def f():
res = await ezkl.calibrate_settings("input.json", "model_4.onnx", "settings.json","resources")
nest_asyncio.apply()
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
loop = asyncio.get_event_loop()
loop.run_until_complete(f())
print("test")
答: 暂无答案
上一个:js 中的异步有序队列执行器
评论