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.1.tar.gz (33.7 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.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flockfile-0.2.1.tar.gz
  • Upload date:
  • Size: 33.7 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.1.tar.gz
Algorithm Hash digest
SHA256 e876477afd62823d69c6fecb841ece6b8a5f1dd3b9b0896eae85f2a7ff58c50f
MD5 ca4ece0c5a5dabc97e89aa28f5de6225
BLAKE2b-256 47562efb59985f5bd2943856518c45f60924fbe0333ef0a24712990fd70e793e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flockfile-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 13f9d51080796952294dfcbb078ca083dbaa06a3d90614dd0e8a25ba828e4372
MD5 7cd0e792b7bad7b64270476350e8bca6
BLAKE2b-256 b8259aa82c6e18481f55147c9dcf49ece33a9a84153923f1877b80f1ce81bc14

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.3

2 files

This release

0.2.1 This release

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