[issue33369] Removing Popen log files in threads is racy on Windows
Peter Boström
report at bugs.python.org
Fri Apr 27 12:56:30 EDT 2018
Peter Boström <python at pbos.me> added the comment:
Wow that's old, yeah that's fair (I wouldn't expect this to be backported to any old releases).
Our current "workaround" is to try os.remove, sleep, repeat X times. This seems still racy and not something we'd like to have in our script if it can be resolved upstream. Retried on 2.7.15rc1:
C:\src>del *.log
Could Not Find C:\src\*.log
C:\src>C:\Python2.7.15rc1\python.exe --version
Python 2.7.15rc1
C:\src>C:\Python2.7.15rc1\python.exe racy_windows.py
Logging to 5656.log
Logging to 13068.log
Logging to 27620.log
Logging to 18384.log
Removing 5656.log
ERxception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python2.7.15rc1\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\Python2.7.15rc1\lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "racy_windows.py", line 19, in __call__
os.remove(file_name)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: '5656.log'
emoving 13068.log
R
emoving 27620.log
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Python2.7.15rc1\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\Python2.7.15rc1\lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "racy_windows.py", line 19, in __call__
os.remove(file_name)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: '27620.log'
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Python2.7.15rc1\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\Python2.7.15rc1\lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "racy_windows.py", line 19, in __call__
os.remove(file_name)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process: '13068.log'
Removing 18384.log
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33369>
_______________________________________
More information about the Python-bugs-list
mailing list