我试图使用Azure上的异步来加快处理时间,但是当我运行它(即RuntimeError: asyncio.run() cannot be called from a running event loopformat(err))
await entity_linking2(client,ace)
asyncio.run(main())
我试图用上面的异步代码运行它,但是收到了一个错误RuntimeErro
从看来,启动异步应用程序的推荐方法是使用asyncio.run(),因此我的应用程序如下所示: # Everything here can use在其他语言中,我会永远调用事件循环。create_tasks_and_register_callbacks(o)
loop.run_forever()
这里的问题是,即使在线程上创建并注册了事件循环,但当我在函数中调用
for x in range(3)] results = asyncio.run:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py",第108行,关闭Administrator\AppData\Local\Programs\Python\Python310
我的第一个想法是用asyncio.run()调用每个协程。不幸的是,在第一次测试之后,我开始收到运行时异常。运行此脚本时,将为test2引发一个RuntimeError: There is no current event loop in thread 'MainThread'.。对我来说,这听起来似乎可以在一个程序中多次调用asyncio.run(),尽管不推荐这样做。无论如何,当错误指向一个不存在的事件循环时,我决定手动管理事件循环,并提出了以下
但是,我得到的RuntimeError: There is no current event loop in thread 'MainThread'错误似乎是由我的主函数中有两个异步请求引起的。def main(): asyncio.run(post_message("the project'invalid_auth', 'channel_not_found
housedetail.htm', 'http://zhaoshangyonghefu010.fang.com/house/1010126863/housedetail.htm']但是,它返回RuntimeError: asyncio.run() cannot be called from a running event loop
有什么问题吗?