You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a strange bug when trying to lock a file on a network file-system mounted inside a container, where the lock file was created but for some reason it seems as though the file-handle wasn't properly returned. My process then got stuck waiting for the lock to be released (when it had in fact created the lock). Looking at the following code, it seems that if the OSError errno isn't EEXIST, ENOENT or EACCES, then it is assumed the file is locked
try:
fd=os.open(self._lock_file, mode)
exceptOSErrorasexception:
if (exception.errno==EEXIST# expected if cannot lock or (ifexception.errno==EACCESandsys.platform=="win32"): # note windows does not allow you to make a folder r/o only files passelse:
raise
Or do you actually want the code to keep attempting to try creating the lock on other OSErrors?
The text was updated successfully, but these errors were encountered:
I agree I think it would be better to make sure unknown errors propagate, instead of causing an infinite loop.
I found another situation where this becomes a problem.
On Windows, if the name of the file given is invalid, such as forgetting to to double backspace on windows, the EINVAL message is not accounted for in the error handling.
importfilelockfilename="C:\path\to\lock\but\backslash\is\not\escaped"withfilelock.filelock(filename):
pass# waits forever and never completes
If you had just tried to open the file, you would see the following message
I ran into a strange bug when trying to lock a file on a network file-system mounted inside a container, where the lock file was created but for some reason it seems as though the file-handle wasn't properly returned. My process then got stuck waiting for the lock to be released (when it had in fact created the lock). Looking at the following code, it seems that if the OSError errno isn't EEXIST, ENOENT or EACCES, then it is assumed the file is locked
https://github.com/tox-dev/py-filelock/blob/4730a40b87cc4b094330b2af7723658428323d60/src/filelock/_soft.py#L23-L32
wouldn't it be more robust to do something like
Or do you actually want the code to keep attempting to try creating the lock on other OSErrors?
The text was updated successfully, but these errors were encountered: