Skip to content

fix: clean up temp directory in JupyterCodeExecutor.stop()#7394

Open
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:main
Open

fix: clean up temp directory in JupyterCodeExecutor.stop()#7394
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:main

Conversation

@Jah-yee
Copy link

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

Summary

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.

Fix

  • Uses tempfile.TemporaryDirectory() instead of tempfile.mkdtemp() when output_dir is None
  • Stores the reference so it gets cleaned up automatically when stop() is called or when the object is destroyed

Fixes #7389

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.

This fix:
- Uses tempfile.TemporaryDirectory() instead of tempfile.mkdtemp() when
  output_dir is None
- Stores the reference so it gets cleaned up automatically when stop() is
  called or when the object is destroyed

Fixes microsoft#7389
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