-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lock on NFS mount not working #92
Comments
Hello there, I'm the writer of the Thank you for the great package, and we hope to see this get fixed! Shay |
There have been other reports regarding NFS in the past: #66 Locking with NFS is rather problematic, while it's not entirely impossible to do it, it absolutely kills your performance in my experience. Having that said, this specific issue seems to be an uncaught exception that I need to fix :) |
Can this be reopened? (should issues realy be closed when they are stale? I'm questioning this as the report is perfectly valid IMHO and just missing catched exception can still be implemented at least) |
Sorry about that, it seems I have misconfigured the stalebot. |
Thank you for re-opening! |
@wolph Is there a solution being worked on? Or is the label just meant to avoid the stalebot actions? |
@rpmcginty I believe it's already fixed on dev but I haven't created a new release yet. I'm having issues with recreating so if you could test it, that would be fantastic! |
certainly! I installed via vcs url but was met with the same issue. Here is a script I used to test. The working directory is on an AWS EFS file system (NFS) import portalocker
with portalocker.Lock('test.lock', 'wb') as fh:
print('wb Locked')
fh.write('Locked\n'.encode())
print('wb Unlocked')
with portalocker.Lock('test.lock', 'r') as fh:
print('r Locked')
print(fh.read())
print('r Unlocked') I received the following error
It appears to fail only on the readonly locks. I should note that it happens for both 'r' and 'rb' @wolph do we need to modify the usage at all? |
That looks like the current "fix" is at least effective in that it throws the correct exception now. Beyond that I'm not sure what else I can do honestly. It appears that the filesystem doesn't support read only locks for this case. For cases like these I created the RedisLock that work across multiple networked systems and is not limited by filesystems at all. There's also a small chance that lockf as opposed to flock works in this case, it can be changed by overriding the LOCKER attribute: portalocker/portalocker/portalocker.py Line 95 in a0c5c75
It's should be noted that different systems behave differently with lockf (Linux vs bsd for example) |
I've published a new release with the fix that gives the correct exceptions. I'm not sure if there's a better fix available here... the underlying filesystem simply doesn't support these locks so there's little else we can do. A nice and safe option could be to use Redis locks, those always work: https://github.com/wolph/portalocker/?tab=readme-ov-file#redis-locks |
Hello,
I create this issue because it seems to me that portalocker does not work well with NFS mount. The problem was discovered while using cachier package : python-cachier/cachier#128
The text was updated successfully, but these errors were encountered: