Antoine Pitrou <pit...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue14077>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to