Skip to main content

Dirlock

PyPi badge pytest badge

A simple directory-based lock implementation for Python. This package provides a lightweight and effective way to coordinate access to shared resources using a lock directory mechanism. This does not require any file locking capabilities of the underlying filesystem or network share.

Installation

Install the package via pip:

pip install dirlock

Usage

You can use the DirLock class to acquire and release locks in your Python code. The class also supports usage within a with clause for convenience.

Example: Using the Lock Explicitly

import time
from dirlock import DirLock

lock_dir_path = "/tmp/mylockdir.lock"
lock = DirLock(lock_dir_path)

print("Acquire lock...")
lock.acquire()
print("Lock acquired!")

# Perform critical section tasks here
# Simulating work
time.sleep(5)

# Release the lock
lock.release()
print("Lock released.")

Example: Using the Lock in a with Clause

import time
from dirlock import DirLock

lock_dir_path = "/tmp/mylockdir.lock"

with DirLock(lock_dir_path) as lock:
    print("Lock acquired!")
    # Perform critical section tasks
    time.sleep(5)  # Simulate work
    print("Work done!")

# The lock is automatically released when the block exits.
print("Lock released.")

Parameters

  • lock_dir (str): The path to the lock directory.
  • retry_interval (float, default=0.1): Time to wait before retrying if the lock cannot be acquired.
  • timeout_interval (float, default=-1): Timeout for acquiring lock. Set to negative value for no timeout.

Change Default Values

You can change the default value for retry_interval via DirLock.retry_interval=<new_value>.

License

This package is licensed under the MIT License.

Metadata

Release files for dirlock 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dirlock 0.3
File Size Uploaded Provenance Actions
dirlock-0.3.tar.gz 6.8 kB With provenance Details for dirlock-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dirlock 0.3
File Interpreter ABI Platform Actions
dirlock-0.3-py3-none-any.whl Python 3 none any Details for dirlock-0.3-py3-none-any.whl

Total release size: 10.5 kB

Release files / dirlock-0.3.tar.gz

Download URL dirlock-0.3.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d66ed2d8c819189abe79a346341a9d6f4e8effdfb3473611e3e91e294533f9c8
BLAKE2b-256 checksum
How to use checksums
95ea4b11fe6a6568d7933860c16bf48e29829589e7e69a744a276e2d2f5ff820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2025.

Transparency log

Release files / dirlock-0.3-py3-none-any.whl

Download URL dirlock-0.3-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65ada1bcb5ee178b852007be13626bac97bf6a6f6ebc233ee876db5e5be4e270
BLAKE2b-256 checksum
How to use checksums
8860ba027b1bd263d169346f8be536a5509ddb790c75a61e47f09c3b7d143e5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2025.

Transparency log

Security for dirlock 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dirlock-0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page