[New-bugs-announce] [issue44105] tempfile.TemporaryDirectory deleted after call to subprocess.run in threads

Colas Le Guernic report at bugs.python.org
Mon May 10 17:39:01 EDT 2021


New submission from Colas Le Guernic <colas.le.guernic at gmail.com>:

Yet another weird bug when one creates sub-processes from threads.
I found several issues mentioning ThreadPoolExecutor and subprocess.run but I believe this one is different.

When creating a temporary directory with tempfile.TemporaryDirectory (with or without context manager) it is sometimes deleted by a call to subprocess.run when both occurs inside a task sent to a ThreadPoolExecutor created without a context manager (that last part is very odd).

Running the attached file on python 3.8.5 or 3.8.10 shows the issue only occurs if the executor is not created through a context manager.

The bug does not seem to occur on python 3.9.5 or 3.10.0b1.

Using a ProcessPoolExecutor seems to fix the issue too.

----------
files: test_tmpdir.py
messages: 393436
nosy: colas.le.guernic
priority: normal
severity: normal
status: open
title: tempfile.TemporaryDirectory deleted after call to subprocess.run in threads
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file50035/test_tmpdir.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44105>
_______________________________________


More information about the New-bugs-announce mailing list