-
-
Notifications
You must be signed in to change notification settings - Fork 128
What happens if another type of OSError is raised when attempting to create a soft lock? #147
Copy link
Copy link
Closed
Labels
Description
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
wouldn't it be more robust to do something like
try:
fd = os.open(self._lock_file, mode)
except OSError as exception:
if (exception.errno == EEXIST # expected if cannot lock
or (if exception.errno == EACCES and sys.platform == "win32"): # note windows does not allow you to make a folder r/o only files
pass
else:
raiseOr do you actually want the code to keep attempting to try creating the lock on other OSErrors?
Reactions are currently unavailable