GithubHelp home page GithubHelp logo

lock on NFS mount not working about portalocker HOT 9 OPEN

alcoat avatar alcoat commented on June 21, 2024
lock on NFS mount not working

from portalocker.

Comments (9)

wolph avatar wolph commented on June 21, 2024 1

Sorry about that, it seems I have misconfigured the stalebot.

from portalocker.

rpmcginty avatar rpmcginty commented on June 21, 2024 1

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

wb Locked
--
wb Unlocked
Traceback (most recent call last):
File "/init/test.py", line 12, in <module>
with portalocker.Lock('test.lock', 'rb') as fh:
File "/home/user/merlin_env/lib/python3.9/site-packages/portalocker/utils.py", line 163, in __enter__
return self.acquire()
File "/home/user/merlin_env/lib/python3.9/site-packages/portalocker/utils.py", line 290, in acquire
raise exceptions.LockException(exception)
portalocker.exceptions.LockException: [Errno 9] Bad file descriptor

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?

from portalocker.

shaypal5 avatar shaypal5 commented on June 21, 2024

Hello there,

I'm the writer of the cachier package, and I'm just chiming in to add that this is the second time file locking on NFS mounts seems to be an issue for us as a user package. This the the first:
python-cachier/cachier#86

Thank you for the great package, and we hope to see this get fixed!

Shay

from portalocker.

wolph avatar wolph commented on June 21, 2024

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.
If at all possible I would highly recommend using Redis Locks instead: https://github.com/wolph/portalocker#redis-locks

Having that said, this specific issue seems to be an uncaught exception that I need to fix :)

from portalocker.

carnil avatar carnil commented on June 21, 2024

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)

from portalocker.

carnil avatar carnil commented on June 21, 2024

Sorry about that, it seems I have misconfigured the stalebot.

Thank you for re-opening!

from portalocker.

rpmcginty avatar rpmcginty commented on June 21, 2024

@wolph Is there a solution being worked on? Or is the label just meant to avoid the stalebot actions?

from portalocker.

wolph avatar wolph commented on June 21, 2024

@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!

from portalocker.

wolph avatar wolph commented on June 21, 2024

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:

LOCKER = fcntl.flock

It's should be noted that different systems behave differently with lockf (Linux vs bsd for example)

from portalocker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.