Skip to content

fix: clean up temporary directory in JupyterCodeExecutor.stop()#7389

Open
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/jupyter-temp-cleanup
Open

fix: clean up temporary directory in JupyterCodeExecutor.stop()#7389
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix/jupyter-temp-cleanup

Conversation

@Jah-yee
Copy link

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

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 #7382

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
Jah-yee added a commit to Jah-yee/autogen that referenced this pull request Mar 13, 2026
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