Skip to main content

Flock with Context Manager

A flock implementation using Python's context manager.

Installation

pip3 install flock-context-manager

Usage

"""Demonstration script for flock with context manager"""

from multiprocessing import Pool
from os import getpid
from time import sleep

from flock_context import FLockContext

LOCK_FILE = "demo.lock"


def task():
    """Your mutually exclusive task goes here"""

    pid = getpid()

    print(f"[{pid}] Getting Lock")
    with FLockContext(LOCK_FILE):
        print(f"[{pid}] Lock Obtained - sleeping for 2 seconds")
        sleep(2)
    print(f"[{pid}] Lock Released")


if __name__ == "__main__":
    print("Starting")
    with Pool(3, task) as pool:
        pool.close()
        pool.join()
    print("Done")

Release files for flock-context-manager 1.0.0

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

Source distribution (sdist)

Source distribution for flock-context-manager 1.0.0
File Size Uploaded
flock_context_manager-1.0.0.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flock-context-manager 1.0.0
File Interpreter ABI Platform
flock_context_manager-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.2 kB

Release files / flock_context_manager-1.0.0.tar.gz

Download URL flock_context_manager-1.0.0.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3db23b74feff048ce4a98c18ca5d9cfb1a6f1ab021c28a1a375c1d171c23ceac
BLAKE2b-256 checksum
How to use checksums
b7f99d63844a30a5398fb8ac9504f84756d96c30d27fa5083f05c1aa45913d87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Nov 16, 2025.

Transparency log

Release files / flock_context_manager-1.0.0-py3-none-any.whl

Download URL flock_context_manager-1.0.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5195c18473a7e9ca7e9c688ffcc3ac98aeec0f4b060b3b6cf2df3fa89773cb03
BLAKE2b-256 checksum
How to use checksums
6cc523162802a471880bd12b0b4595419dde6ac2450b1a8e0873922a8ca13d74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Nov 16, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

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