Skip to content
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

Closed
aiwenForGit opened this issue Mar 8, 2024 · 4 comments
Closed

Comments

@aiwenForGit
Copy link

之前在运行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)

      这个错误是由于asyncio事件循环已经关闭导致的。通常在异步程序结束时,事件循环会自动关闭。但是在某些情况下,事件循环可能会意外关闭,从而导致这个错误。

虽然这个错误看起来很可怕,但实际上它不会影响程序的正常运行和输出结果。这只是一个警告信息,表示在程序结束时,事件循环已经关闭,因此无法正常关闭一些底层连接。

为了避免这个警告,你可以在程序结束前手动关闭事件循环,这样就不会触发这个错误了。

@Maplemx
Copy link
Owner

Maplemx commented Mar 10, 2024

fixed in 647dc49

@Maplemx
Copy link
Owner

Maplemx commented Mar 11, 2024

optimized in 0fa3da4

@Maplemx
Copy link
Owner

Maplemx commented Mar 11, 2024

@Maplemx Maplemx closed this as completed Mar 11, 2024
@aiwenForGit
Copy link
Author

非常感谢莫总的认可,希望agently越来越好。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants