GithubHelp home page GithubHelp logo

Comments (4)

wolph avatar wolph commented on May 29, 2024

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.

joanlopez avatar joanlopez commented on May 29, 2024

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.

wolph avatar wolph commented on May 29, 2024

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.

wolph avatar wolph commented on May 29, 2024

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)

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.