[New-bugs-announce] [issue30028] make test.support.temp_cwd() fork-safe
Anselm Kruis
report at bugs.python.org
Sun Apr 9 16:00:25 EDT 2017
New submission from Anselm Kruis:
The context manager test.support.temp_cwd() creates a temporary directory and removes it on exit. The test runner test.regrtest uses this context manager.
I observed an annoying behaviour of test.support.temp_cwd() on Linux/UNIX: if the code, that runs in the temp_cwd() context forks and if the forked child terminates (without calling exec), then the temporary directory will be removed twice: by the child and by the parent. This can cause errors in the parent, if the parent tries to access the no longer existing directory.
I discovered this problem, when a test in test_multiprocessing_fork failed and the test directory for the complete test.regrtest-run got removed. Of course all other tests failed too.
I propose to modify test.support.temp_cwd() to remove the created directory only, if the process id (os.getpid()) is unchanged. I'll create a pull request.
----------
components: Tests
messages: 291396
nosy: anselm.kruis
priority: normal
severity: normal
status: open
title: make test.support.temp_cwd() fork-safe
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30028>
_______________________________________
More information about the New-bugs-announce
mailing list