Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions tools/filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

# Modules
# ------------------------------------------------
from contextlib import suppress
import logging
import os
import threading
Expand Down Expand Up @@ -410,8 +411,12 @@ def _acquire(self):
def _release(self):
fd = self._lock_file_fd
self._lock_file_fd = None
os.unlink(self._lock_file)
fcntl.flock(fd, fcntl.LOCK_UN)
# Probably another instance of the application
# that released the file lock.
with suppress(FileNotFoundError):
os.unlink(self._lock_file)
with suppress(OSError):
fcntl.flock(fd, fcntl.LOCK_UN)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are both of these needed to fix your issue? Or is just one or the other enough?

It seems like neither should be necessary, since if we are holding the lock we should always be able to unlock it, right? It should be impossible for another process acquire or delete the lock file until LOCK_UN, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The os.unlink is what I observed to cause trouble (also seen in the issue linked in PR description). The other one, should not be necessary.

It seems like neither should be necessary, since if we are holding the lock we should always be able to unlock it, right? It should be impossible for another process acquire or delete the lock file until LOCK_UN, no?

I would think so, but in practice, os.unlink gets executed after someone else deletes it. Could it be an issue with the port, and not the filelock.py?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think so, but in practice, os.unlink gets executed after someone else deletes it.

Im struggling to see how anyone else could be deleting this file. But clearly it is happening, I just want to know how / why

os.close(fd)
return None

Expand Down
Loading