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

Error during cleanup of server sqlite: Attempted to exit cancel scope in a different task than it was entered in #252

Open
xiongzhp opened this issue Mar 10, 2025 · 5 comments · May be fixed by #353

Comments

@xiongzhp
Copy link

Describe the bug
When running examples\clients\simple-chatbot\mcp_simple_chatbot\main.py

2025-03-10 19:55:12,391 - ERROR - Error during cleanup of server sqlite: Attempted to exit cancel scope in a different task than it was entered in
2025-03-10 19:55:12,467 - ERROR - an error occurred during closing of asynchronous generator <async_generator object stdio_client at 0x0000014698D39930>

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: win10 and ubuntu
@jritsema
Copy link

I got the same error.

This is the only example I've seen of using python to manage multiple mcp servers (and it doesn't seem to work). Are there others?

@s-konnex-engine
Copy link

s-konnex-engine commented Mar 12, 2025

having the same issue.

immediately after receiving an OK response from the LLM, get this error.

EDIT: from Claude: The key problem is a violation of a fundamental principle in asynchronous programming. In async frameworks (like Python's asyncio, trio, or curio), a "cancel scope" is a context that manages cancellation of operations. This error indicates the code is trying to exit a cancel scope from a different task than the one where it was created.

I may have a solution but I won't be able to test it until about 6 hours time as i have to go out.

Fingers crossed. but the solution is from Claude. It's already sent me on a number of wild goose chases w/r/t this exact issue. but i have a better understanding of it now so i should be able to better analyze the proposed fix line by line once i attempt to implement it.

I'll keep you posted

@clareliguori clareliguori linked a pull request Mar 23, 2025 that will close this issue
9 tasks
@WikiHkz
Copy link

WikiHkz commented Apr 1, 2025

I met the same problem, how did you solve it?

@WikiHkz
Copy link

WikiHkz commented Apr 1, 2025

having the same issue.

immediately after receiving an OK response from the LLM, get this error.

EDIT: from Claude: The key problem is a violation of a fundamental principle in asynchronous programming. In async frameworks (like Python's asyncio, trio, or curio), a "cancel scope" is a context that manages cancellation of operations. This error indicates the code is trying to exit a cancel scope from a different task than the one where it was created.

I may have a solution but I won't be able to test it until about 6 hours time as i have to go out.

Fingers crossed. but the solution is from Claude. It's already sent me on a number of wild goose chases w/r/t this exact issue. but i have a better understanding of it now so i should be able to better analyze the proposed fix line by line once i attempt to implement it.

I'll keep you posted

Many 6 hours have passed now, are you back?

@Broyojo
Copy link

Broyojo commented Apr 1, 2025

asyncio.gather() cannot be used since the order of initialization is unknown. we need to know this initialization order since we need to close the servers in reverse initialization order. let me know if there is a way to launch the servers in parallel, since this is a big bottleneck seemingly.

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

Successfully merging a pull request may close this issue.

5 participants