GithubHelp home page GithubHelp logo

Comments (15)

aigoncharov avatar aigoncharov commented on May 28, 2024

+1 for Win 10

from portalocker.

vitidev avatar vitidev commented on May 28, 2024

+1 for python 3.6

from portalocker.

aigoncharov avatar aigoncharov commented on May 28, 2024

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.

vitidev avatar vitidev commented on May 28, 2024

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

aigoncharov avatar aigoncharov commented on May 28, 2024

@vitidev I see. I just pointed that if wee need to lock the whole file -1 is not the answer.

from portalocker.

RazerM avatar RazerM commented on May 28, 2024

These lines:

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.

RazerM avatar RazerM commented on May 28, 2024

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.

TWAC avatar TWAC commented on May 28, 2024

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.

wolph avatar wolph commented on May 28, 2024

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.

vitidev avatar vitidev commented on May 28, 2024

Second bug "AttributeError: module 'msvcrt' has no attribute 'LK_RLOCK'" not fixed in 1.1.0

from portalocker.

wolph avatar wolph commented on May 28, 2024

Oops, Github automatically closed this. I've reopened.

from portalocker.

vitidev avatar vitidev commented on May 28, 2024

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.

wolph avatar wolph commented on May 28, 2024

Fixed on develop, I'm releasing a new version today :)

from portalocker.

wolph avatar wolph commented on May 28, 2024

Delaying on that new release a bit, python 3.x on windows still won't work with exclusive locks correctly for me

from portalocker.

wolph avatar wolph commented on May 28, 2024

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)

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.