Skip to content

Close resource issue #665

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

Open
xingwenkai opened this issue May 8, 2025 · 0 comments
Open

Close resource issue #665

xingwenkai opened this issue May 8, 2025 · 0 comments

Comments

@xingwenkai
Copy link

Since there are too many synchronous methods in my chat program, it is difficult to change them all to asynchronous methods, so I use

def run(self):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

  # initialization
  loop.run_until_complete(self.init_mcp_chat_server())
  
  # list tool
  list_tools, self._tools_description = loop.run_until_complete(self._init_prompt_tools())

  # close
  loop.run_until_complete(self.mcp_server_cleanup())

I have verified that the correct data can be obtained,But when I close:loop.run_until_complete(self.mcp_server_cleanup()) ,Will report an error :

Attempted to exit cancel scope in a different task than it was entered in

How should I solve this problem?

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

1 participant