Skip to content

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

Open
SinzoL wants to merge 1 commit intomicrosoft:mainfrom
SinzoL:fix/7217-jupyter-executor-tempdir-leak
Open

fix: clean up temporary directory in JupyterCodeExecutor.stop()#7382
SinzoL wants to merge 1 commit intomicrosoft:mainfrom
SinzoL:fix/7217-jupyter-executor-tempdir-leak

Conversation

@SinzoL
Copy link

@SinzoL SinzoL 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. Switch from mkdtemp() to TemporaryDirectory() and call cleanup() in stop() so the temp dir is properly removed when the executor is stopped. Fixes #7217

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.

Switch from mkdtemp() to TemporaryDirectory() and call cleanup() in
stop() so the temp dir is properly removed when the executor is
stopped.

Fixes microsoft#7217
Jah-yee pushed 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.

Fixes microsoft#7382
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.

JupyterCodeExecutor leaks temporary output directory on stop — inconsistent with other executors

1 participant