Comments (15)
+1 for Win 10
from portalocker.
+1 for python 3.6
from portalocker.
Though it seemed like a simple AttributeError which could be fixed with simple
getattr(msvcrt, 'LK_RLOCK', msvcrt.LK_RLCK)
it goes deeper for me.
Having applied the fix above I stumbled upon another issue: my python interpreter started failing.
The issue is:
msvcrt.locking(file_.fileno(), mode, -1)
If I put a random number instead of -1 it starts working.
from portalocker.
@keenondrums
msvcrt.locking(fd, mode, nbytes) where nbytes -"the locked region of the file extends from the current file position for nbytes bytes, and may continue beyond the end of the file"
We need to lock whole file.
from portalocker.
@vitidev I see. I just pointed that if wee need to lock the whole file -1 is not the answer.
from portalocker.
savepos = file_.tell()
if savepos:
file_.seek(0)
try:
msvcrt.locking(file_.fileno(), mode, -1)
need to be replaced with something like this:
savepos = file_.tell()
file_.seek(0, os.SEEK_END)
size = file_.tell()
file_.seek(0)
try:
msvcrt.locking(file_.fileno(), mode, size)
I see no indication from the documentation that -1 is a valid value for the third argument. The msvcrt.locking
causes Python to silently exit, which must be a Python bug, though.
from portalocker.
After updating 3.5.2 to 3.5.3 and still getting the crash, I verified that 2.7 and 3.4 don't cause a crash then filed a bug: http://bugs.python.org/issue29392
from portalocker.
The msvcrt module uses _locking which says "It is possible to lock bytes past end of file".
Perhaps one can simply lock as much possible, 2147483647? Any larger value gives OverflowError: Python int too large to convert to C long
.
@techtonik added -1, what do you think?
from portalocker.
It looks like the bug was fixed so that's good :)
http://bugs.python.org/issue29392
Still... doesn't help much with the bug though. Not sure I can help much here guys (no windows) but I'll help with anything I can offer.
from portalocker.
Second bug "AttributeError: module 'msvcrt' has no attribute 'LK_RLOCK'" not fixed in 1.1.0
from portalocker.
Oops, Github automatically closed this. I've reopened.
from portalocker.
If fix in line 14 mode = msvcrt.LK_RLOCK -> mode = msvcrt.LK_RLCK
I did not find LK_RLOCK in any python documentation and I think it's a typo
from portalocker.
Fixed on develop, I'm releasing a new version today :)
from portalocker.
Delaying on that new release a bit, python 3.x on windows still won't work with exclusive locks correctly for me
from portalocker.
The new release works perfect for me on Python 2.x and 3.x on Windows, OS X and Linux
from portalocker.
Related Issues (20)
- Sorry for OT HOT 2
- Neither exclusive nor shared locks working as expected on Windows HOT 2
- Windows shared lock with Python 3 HOT 11
- 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
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.