Comments (4)
Can you show the code you are using? Generally you would lock the actual file instead of create a lockfile using this application.
If you require this sort of operation I could easily create a utility function to handle this of course :)
from portalocker.
Our project is available here: https://earth.bsc.es/gitlab/es/autosubmit
I think this incoherence is happening because we are not doing the proper usage of the library.
Our tool is intended to run different experiments in different supercomputers (workflow manager). In this case, our experiments are composed by some configuration files, some temporal files, etc.
This is why we are using a fictional .lock
file inside the experiments's folder. For example, to prevent running the same experiment twice at the same time (what could produce internal incoherences).
What could be a proper way of usage for this purpose?
from portalocker.
There isn't one I suppose :)
It's a use-case I haven't considered before but I'm implementing a new utility function as we speak which will do the trick for you
from portalocker.
I've added a utility class to easily create a temporary lockfile which will always* disappear after unlocking.
You can use it like this:
import portalocker
with portalocker.TemporaryFileLock(optional_filename_here):
# do something here
pass
Or:
import portalocker
lock = portalocker.TemporaryFileLock()
lock.acquire()
# do something here
# the lock automatically gets cleaned when the program exits but manually unlocking is possible:
lock.release()
Can you give it a try?
*when the process is killed using "kill -9" it won't have the chance to cleanup.
from portalocker.
Related Issues (20)
- Rlock - with limit? HOT 6
- What are the different locking mechanisms? HOT 2
- Fix `ResourceWarning` when `AlreadyLocked` HOT 6
- Declare PEP 561 compliance (type checking support) HOT 3
- 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
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.