Skip to content

fix: make McpWorkbench.stop() idempotent#7396

Open
Jah-yee wants to merge 3 commits intomicrosoft:mainfrom
Jah-yee:fix-mcp-workbench-idempotent
Open

fix: make McpWorkbench.stop() idempotent#7396
Jah-yee wants to merge 3 commits intomicrosoft:mainfrom
Jah-yee:fix-mcp-workbench-idempotent

Conversation

@Jah-yee
Copy link

@Jah-yee Jah-yee commented Mar 13, 2026

Summary

  • Makes McpWorkbench.stop() idempotent by returning early if _actor is None
  • Instead of raising RuntimeError("McpWorkbench is not started. Call start() first."), it now silently returns
  • This prevents unhandled exceptions when __del__ calls stop() via asyncio.create_task

Why

When the workbench was never started (or start() failed), the RuntimeError propagates as an unhandled exception in the background task. This is problematic because:

  1. __del__ can call stop() via asyncio.create_task
  2. If the workbench was never started, the RuntimeError becomes unhandled

Fixes

Jah-yee and others added 3 commits March 13, 2026 16:06
When output_dir is None, JupyterCodeExecutor creates a temp directory
via tempfile.mkdtemp() but never cleans it up in stop(). This leaks a
directory per executor lifetime.

Fixes microsoft#7382
…odeExecutor.stop()

Fixes microsoft#7383 - Ensures temporary directory cleanup happens after the Docker
container is stopped, preventing potential issues with files being deleted
while still in use by the container.
- Return early if actor is None instead of raising RuntimeError
- This prevents unhandled exceptions when __del__ calls stop()
- Consistent with DockerCommandLineCodeExecutor.stop() behavior
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 this pull request may close these issues.

1 participant