Comments (9)
Sorry about that, it seems I have misconfigured the stalebot.
from portalocker.
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.
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.
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.
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.
Sorry about that, it seems I have misconfigured the stalebot.
Thank you for re-opening!
from portalocker.
@wolph Is there a solution being worked on? Or is the label just meant to avoid the stalebot actions?
from portalocker.
@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.
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)
from portalocker.
Related Issues (20)
- redis submodule cannot be imported due to circular import HOT 4
- race condition for⦠file metadata? HOT 4
- Setting the DenyMode against a file HOT 2
- is lock reenterable? HOT 2
- distutils was depreacted in Python 3.10 HOT 2
- Timeout not working with SHARED flag HOT 4
- Better Examples Needed HOT 3
- LockException(OSError(22, 'Invalid argument')) when using NON_BLOCKING flag on Linux HOT 2
- DLL load failed while importing win32file HOT 1
- What is the actual license for this project? HOT 1
- fileno support HOT 2
- Mismatch between documentation and implementation HOT 3
- How to lock a file but be able to read it HOT 4
- Python 3.12: ModuleNotFoundError: No module named 'distutils' HOT 2
- Require explicit name for BoundedSemaphore()? HOT 9
- docs files are installed in the wrong location HOT 5
- Version 2.7.0 Released in January 2023 was updated recently to remove support for Python 3.7 HOT 13
- 'portalocker' has no attribute 'LockFlags'
- Is this 2016 StackOverflow answer still accurate? (`fh = open(p); Lock(fh)` vs. `with Lock(p) as fh`) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from portalocker.