[issue14077] sporadic test_multiprocessing failure
Antoine Pitrou
report at bugs.python.org
Tue Feb 21 21:37:49 CET 2012
Antoine Pitrou <pitrou at free.fr> added the comment:
I am proposing the following patch to have a better unique filename:
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -129,8 +129,8 @@ def _path_absolute(path):
def _write_atomic(path, data):
"""Function to write data to a path atomically."""
- # id() is used to generate a pseudo-random filename.
- path_tmp = '{}.{}'.format(path, id(path))
+ # getpid() and id() are used to generate a pseudo-random filename.
+ path_tmp = '{}.{}-{}'.format(path, _os.getpid(), id(path))
fd = _os.open(path_tmp, _os.O_EXCL | _os.O_CREAT | _os.O_WRONLY, 0o666)
try:
# We first write data to a temporary file, and then use os.replace() to
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14077>
_______________________________________
More information about the Python-bugs-list
mailing list