Comments (2)
A few years ago the library switched to LockFileEx to make sure we can have shared locks again: #30
Beyond that... I'm honestly not entirely sure what locking options Windows has for Python. On stackoverflow I can see a few different options, I wouldn't oppose switching methods if any of those would help: https://stackoverflow.com/questions/29344366/lock-file-for-access-on-windows
I have to say that I'm surprised that there are different incompatible locking methods on Windows, generally you would expect the kernel or the filesystem to implement that and all APIs call the same locking methods internally.
Are you sure it's not a behaviour difference? Looking at the message of bgavrilMS I see this:
If you run the python app first (i.e. create the lock from py), the .NET app waits for the lock to go away. If you run the .NET app first however, the python app crashes because it cannot acquire the lock.
That makes me think that .Net simply keeps waiting for a lock whereas the Python code has a timeout configured. This method is honestly a bit clunky but there is (was?) no good way to get a multi-platform locking timeout otherwise:
https://github.com/WoLpH/portalocker/blob/927d53ef8ba14662104999fcedb5a1e285aeb232/portalocker/utils.py#L153-L161
If you would set the timeout to some ridiculously large number you might get the same behaviour.
from portalocker.
I have to say that I'm surprised that there are different incompatible locking methods on Windows, generally you would expect the kernel or the filesystem to implement that and all APIs call the same locking methods internally.
Yes, I'm equally surprised, too.
I wouldn't oppose switching methods if any of those would help: https://stackoverflow.com/questions/29344366/lock-file-for-access-on-windows
To be clear, I'm not currently suggesting a change from Portalocker. If Portalocker works fine in itself among its existing community, there is no motivation to change it.
Thanks for your input. We will give it more thoughts.
from portalocker.
Related Issues (20)
- 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'
- lock on NFS mount not working HOT 10
- Is this 2016 StackOverflow answer still accurate? (`fh = open(p); Lock(fh)` vs. `with Lock(p) as fh`) HOT 2
- Type hints for utils.Lock.acquire (and __enter__) incorrect HOT 1
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.