mirror of
https://github.com/python/cpython.git
synced 2026-04-14 15:50:50 +00:00
gh-146202: Create tmp_dir in regrtest worker (#146347)
Create tmp_dir in libregrtest.worker since the directory can be different than the --tempdir directory.
This commit is contained in:
parent
306c556fdb
commit
bcff99cb3f
3 changed files with 6 additions and 6 deletions
|
|
@ -452,12 +452,6 @@ def get_temp_dir(tmp_dir: StrPath | None = None) -> StrPath:
|
|||
f"unexpectedly returned {tmp_dir!r} on WASI"
|
||||
)
|
||||
tmp_dir = os.path.join(tmp_dir, 'build')
|
||||
|
||||
# When get_temp_dir() is called in a worker process,
|
||||
# get_temp_dir() path is different than in the parent process
|
||||
# which is not a WASI process. So the parent does not create
|
||||
# the same "tmp_dir" than the test worker process.
|
||||
os.makedirs(tmp_dir, exist_ok=True)
|
||||
else:
|
||||
tmp_dir = tempfile.gettempdir()
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,9 @@ def main() -> NoReturn:
|
|||
worker_json = sys.argv[1]
|
||||
|
||||
tmp_dir = get_temp_dir()
|
||||
# get_temp_dir() can be different in the worker and the parent process.
|
||||
# For example, if --tempdir option is used.
|
||||
os.makedirs(tmp_dir, exist_ok=True)
|
||||
work_dir = get_work_dir(tmp_dir, worker=True)
|
||||
|
||||
with exit_timeout():
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
Fix a race condition in regrtest: make sure that the temporary directory is
|
||||
created in the worker process. Previously, temp_cwd() could fail on Windows if
|
||||
the "build" directory was not created. Patch by Victor Stinner.
|
||||
Loading…
Add table
Add a link
Reference in a new issue