Skip to main content

Flockcontext

https://img.shields.io/travis/AntoineCezar/flockcontext.svg https://img.shields.io/badge/docs-latest-brightgreen.svg https://img.shields.io/coveralls/AntoineCezar/flockcontext.svg https://img.shields.io/pypi/v/flockcontext.svg

Improves fcntl.flock usage.

flock is a Unix command for file locking, the mecanism that controls access restrictions of files.

Usage

Exclusive blocking lock:

from flockcontext import FlockOpen

with FlockOpen('/tmp/my.lock', 'w') as lock:
    lock.fd.write('Locked\n')

Exclusive blocking lock with 1 second timeout:

from flockcontext import FlockOpen

with FlockOpen('/tmp/my.lock', 'w', timeout=1) as lock:
    lock.fd.write('Locked\n')

Exclusive non-blocking lock:

from flockcontext import FlockOpen

try:
    with FlockOpen('/tmp/my.lock', 'w', blocking=False) as lock:
        lock.fd.write('Locked\n')
except IOError as e:
    print('Can not acquire lock')

Shared blocking lock:

from flockcontext import Flock

with FlockOpen('/tmp/my.lock', 'w', exclusive=False) as lock:
    lock.fd.write('Locked\n')

Acquire and release within context:

from flockcontext import FlockOpen

with FlockOpen('/tmp/my.lock', 'w') as lock:
    print('Lock acquired')
    lock.fd.write('Locked\n')

    lock.release()
    print('Lock released')

    lock.acquire()
    print('Lock acquired')
    lock.fd.write('Locked\n')

Locking already opened file:

from flockcontext import Flock

with open('/tmp/my.lock', 'w') as fd:
    with Flock(fd):
        fd.write('Locked\n')

License

  • Free software: BSD license

Metadata

Release files for flockcontext 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 flockcontext 1.0.0
File Size Uploaded Provenance Actions
flockcontext-1.0.0.tar.gz 2.6 kB Without provenance Details for flockcontext-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 6.7 kB

Release files / flockcontext-1.0.0.tar.gz

Download URL flockcontext-1.0.0.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
16c69ffdf483b5bef6cabf70b7fc830d5cf6e8e6708e61bd26a32738c683d523
BLAKE2b-256 checksum
How to use checksums
4dd41274ea691160ab4066e6e206f3d7ae245a81691b7f602f72ffb0d1f24d1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.7

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

Download URL flockcontext-1.0.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e38a0748fb4294591c3e20ae16ba9b4ec30f6e2f0494faf15aed28da4779ddf
BLAKE2b-256 checksum
How to use checksums
34810b88b8aafed29c50236d416af34bba6fd1760c3be801facc387b4b3cb2b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.7

Security for flockcontext 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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