Skip to content
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

Neither exclusive nor shared locks working as expected on Windows #63

Closed
tinducvo opened this issue Apr 13, 2021 · 2 comments
Closed

Neither exclusive nor shared locks working as expected on Windows #63

tinducvo opened this issue Apr 13, 2021 · 2 comments

Comments

@tinducvo
Copy link

tinducvo commented Apr 13, 2021

Morning!

I am trying to use portalocker for some system-wide resource management under Windows.
When I run either of the following from two different programs:
portalocker.lock(fileHandle, portalocker.LOCK_EX)
Or
portalocker.lock(fileHandle, portalocker.LOCK_SH)

I always get the following on the second program:
"LockException: (1, 'The process cannot access the file because another process has locked a portion of the file.')"

My expectation was that exclusive lock is a write lock and the shared lock is a read lock, but instead both:

  • exhibit exclusive locking in Python
  • when locked:
    • can be read from notepad
    • cannot be written from notepad
    • cannot be moved from file explorer
@wolph
Copy link
Owner

wolph commented Apr 15, 2021

The problem with locking mechanisms is that they need to be implemented in the same way by all participating applications. So the big question is... which locking mechanism is notepad/file explorer using.

Apparently there are multiple locking mechanisms on Windows: #58

@tinducvo
Copy link
Author

That makes sense for observations with notepad and file explorer. I see PL uses two methods.

As for the shared lock, the confusion was that I thought it was like a sempahore.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants