-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
出现“RuntimeError: Event loop is closed”的小bug解决方案 #49
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
之前在运行workflow时候多轮次中间经常出现,RuntimeError: Event loop is closed,但结果能够得到,为了解决这个问题,我找了写资料,发觉在agent.py里面改下代码即可,在214行,增加一个try finally即可。
def start_in_theard():
asyncio.set_event_loop(asyncio.new_event_loop())
loop = asyncio.get_event_loop()
try:
reply = asyncio.get_event_loop().run_until_complete(self.start_async(request_type))
reply_queue.put_nowait(reply)
finally:
loop.close()
#reply = asyncio.get_event_loop().run_until_complete(self.start_async(request_type))
#reply_queue.put_nowait(reply)
虽然这个错误看起来很可怕,但实际上它不会影响程序的正常运行和输出结果。这只是一个警告信息,表示在程序结束时,事件循环已经关闭,因此无法正常关闭一些底层连接。
为了避免这个警告,你可以在程序结束前手动关闭事件循环,这样就不会触发这个错误了。
The text was updated successfully, but these errors were encountered: