A flock implementation using Python's context manager.
Project description
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")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flock_context_manager-1.0.0.tar.gz.
File metadata
- Download URL: flock_context_manager-1.0.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3db23b74feff048ce4a98c18ca5d9cfb1a6f1ab021c28a1a375c1d171c23ceac
|
|
| MD5 |
8debe0752b883985c4e114a8d0ab557a
|
|
| BLAKE2b-256 |
b7f99d63844a30a5398fb8ac9504f84756d96c30d27fa5083f05c1aa45913d87
|
Provenance
The following attestation bundles were made for flock_context_manager-1.0.0.tar.gz:
Publisher:
release.yml on joepitt91/flock-context
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flock_context_manager-1.0.0.tar.gz -
Subject digest:
3db23b74feff048ce4a98c18ca5d9cfb1a6f1ab021c28a1a375c1d171c23ceac - Sigstore transparency entry: 702428304
- Sigstore integration time:
-
Permalink:
joepitt91/flock-context@4698bbd4524449b7d9c66d3da5901d67c859396c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/joepitt91
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4698bbd4524449b7d9c66d3da5901d67c859396c -
Trigger Event:
release
-
Statement type:
File details
Details for the file flock_context_manager-1.0.0-py3-none-any.whl.
File metadata
- Download URL: flock_context_manager-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5195c18473a7e9ca7e9c688ffcc3ac98aeec0f4b060b3b6cf2df3fa89773cb03
|
|
| MD5 |
21c7650ef020876dfeaac7efe4339629
|
|
| BLAKE2b-256 |
6cc523162802a471880bd12b0b4595419dde6ac2450b1a8e0873922a8ca13d74
|
Provenance
The following attestation bundles were made for flock_context_manager-1.0.0-py3-none-any.whl:
Publisher:
release.yml on joepitt91/flock-context
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flock_context_manager-1.0.0-py3-none-any.whl -
Subject digest:
5195c18473a7e9ca7e9c688ffcc3ac98aeec0f4b060b3b6cf2df3fa89773cb03 - Sigstore transparency entry: 702428314
- Sigstore integration time:
-
Permalink:
joepitt91/flock-context@4698bbd4524449b7d9c66d3da5901d67c859396c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/joepitt91
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4698bbd4524449b7d9c66d3da5901d67c859396c -
Trigger Event:
release
-
Statement type: