Comments (9)
You are largely correct but you've glossed over a small detail, the directory is randomized by the tempfile.gettempdir()
function:
portalocker/portalocker/utils.py
Lines 430 to 449 in ea5e180
In practice you will never have 2 unrelated applications colliding :)
from portalocker.
tempfile.gettempdir()
always returns /tmp
for me (Ubuntu, not setting TMPDIR, TEMP or TMP). See https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir
>>> import tempfile
>>> tempfile.gettempdir()
'/tmp'
from portalocker.
Oops... in that case I have made a wrong assumption a long time ago and created a semaphore that could cause issues in some cases.
I'm in the process of creating a new release anyhow so I'll make sure to add your suggested NamedBoundedSemaphore
class
from portalocker.
No worries. Happens to the best of us 😄
Thanks for all your hard work.
from portalocker.
As a backstory, I'm guessing this made me think it was random. On my laptop I get this:
>>> tempfile.gettempdir()
'/var/folders/y7/n86bj8vn48vftzwyzdwdpvtc0000gn/T'
Seemed pretty random to me ;)
from portalocker.
Hmm… Is that inside some kind of container or WSL on Windows or something?
from portalocker.
No... that's on OS X
from portalocker.
OK, so that seems to be a per-user $TMPDIR. I think my original observation mostly still holds: Two unrelated applications running as the same user on the same host could interfere with each other.
from portalocker.
Your observation is correct indeed. If I start 2 completely unrelated applications I get the same results.
Furthermore:
$ echo $TMPDIR
/var/folders/y7/n86bj8vn48vftzwyzdwdpvtc0000gn/T/
I really should have read the Python manual, it's pretty clear about this :X
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
- 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
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.