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

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.1.3.tar.gz (4.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: flockfile-0.1.3.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for flockfile-0.1.3.tar.gz
Algorithm Hash digest
SHA256 136c9c4cc1b62f359df534814c4d5acc66792695e6916c5962c390c56fde49d9
MD5 44170555e6307183c80c59532752236a
BLAKE2b-256 e360a509e6e910f82dc77b2948208eeed5ffb2f3a4e1bf03f70a5668ab357ac7

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.3

2 files

0.2.1

2 files

0.2.0

2 files

This release

0.1.3 This release

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