Skip to main content

Fast hierarchical locks

Project description

Hierarchical locks

Allows the caller to lock a "directory", or an individual file.

Locks are, by default, shared, recursive & timed.

First optional argument to the lock manager is the "sep".

Second optional argument is "flags" (default is HiLokFlags.RECURSIVE, can be also be HiLokFlags:STRICT).

from hilok import HiLok, HiLokError, HiLokFlags

h = HiLok()     # default sep is '/', can pass it in here

rd = h.read("/some/path")

# nonblocking, this will fail!
try:
    wr = h.write("/some", block=False)
except HiLokError:
    pass

rd.release()

wr = h.write("/some")

# timeout=0 is the the same as block=False
rd = h.read("/some/path", block=False)

# with syntax is fine:
with h.read("/some/path"):
    pass

Lock modes:

  • HiLokFlags.STRICT : not reentrant, the good mode
  • HiLokFlags.RECURSIVE : fully reentrant, supports escalation (read/write/release-read) and de-escalation (write/read/release-write)
  • HiLokFlags.RECURSIVE_WRITE : only write-locks are reentrant
  • HiLokFlags.RECURSIVE_ONEWAY : can read-lock while holding a write, but not vice-versa

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

hilok-1.3.1-cp311-cp311-win_amd64.whl (96.0 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

hilok-1.3.1-cp311-cp311-macosx_12_0_universal2.whl (80.2 kB view hashes)

Uploaded CPython 3.11 macOS 12.0+ universal2 (ARM64, x86-64)

hilok-1.3.1-cp310-cp310-win_amd64.whl (96.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

hilok-1.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (102.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

hilok-1.3.1-cp310-cp310-macosx_12_0_x86_64.whl (80.3 kB view hashes)

Uploaded CPython 3.10 macOS 12.0+ x86-64

hilok-1.3.1-cp39-cp39-win_amd64.whl (96.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

hilok-1.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (102.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

hilok-1.3.1-cp39-cp39-macosx_10_15_x86_64.whl (83.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page