Skip to main content

flockfile

Just a simple python lock file class using file locks.

Installation

pip install flockfile

Usage

from flockfile import FlockFile, FileNotLocked

# init the class using a file name
# optionally, the directory can be set to something other than /tmp
lock = FlockFile("myscriptname", lock_dir="/tmp")


# lock the file
lock.lock()
# if this is unsuccessful, exception FileNotLocked will be raised.

# the following class method can be used to check lock status
assert lock.check_lock()

# unlock and delete file
lock.unlock()

FlockFile can also be used as a context manager. The lock is acquired on entry (raising FileNotLocked if it cannot be obtained) and released on exit:

from flockfile import FlockFile

with FlockFile("myscriptname", lock_dir="/tmp"):
    # the lock is held here
    ...
# the lock is released and the file deleted here

Questions or Issues?

Please report as a Gitlab issue: https://gitlab.com/rveach/flockfile/issues

A note on the use of AI

This library was initally created by hand and uploaded to PyPI in 2019. A lot has changed, so I've used AI to add a context manager and modernize the toolset. All commits using AI have been tagged as such.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flockfile-0.2.3.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flockfile-0.2.3-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file flockfile-0.2.3.tar.gz.

File metadata

  • Download URL: flockfile-0.2.3.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for flockfile-0.2.3.tar.gz
Algorithm Hash digest
SHA256 bdd89568597a395fd2899399e0034f0ecb785f470991ec4b72d0e21365b496d2
MD5 b5e4e9734cd8ab7b58769b3609192a5f
BLAKE2b-256 3ba209493e084ce3348dcd514ab90cbc5af119f59801a01879db6c7f81d58708

See more details on using hashes here.

File details

Details for the file flockfile-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: flockfile-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for flockfile-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 185b14b7850b9a232336e78202819dcab48e60c0e8c2bd47a9a8e095606a09de
MD5 a5bc05942c5ca21d3be265e096cd4d15
BLAKE2b-256 320a304eef9b42a6bb092e4ddc0280670d32efeae127faacdb9eacf77fc913b5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page