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.0.tar.gz (16.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.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flockfile-0.2.0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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.0.tar.gz
Algorithm Hash digest
SHA256 db3d16c07ff44103a3e033da84c5c51353653637393a87164ad36387b9bd00aa
MD5 7cb7e81f268e9668b39f7ef5c7f5dfb9
BLAKE2b-256 5f2d15d6c2f2d03afd5ef86997f77f024685e5a94e6cb05d58a75335c500da5c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flockfile-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e54b3b9f279c804dece328b0bb57019090dc0ad94b36981c64d5549c90b7540
MD5 783427adb8662fe9c0ee4cfdff450f4f
BLAKE2b-256 54e242409395b824bd333da38c41007fac1fedc517eefdcd92371de6ee8833f4

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.3

2 files

0.2.1

2 files

This release

0.2.0 This release

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