Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

NamedLocks


NamedLocks is a simple library for locking on a name.

Installation

pip install namedlocks

Usage

import asyncio
from random import randint, uniform

from named_locks import AsyncNamedLock

NAMED_LOCKS = AsyncNamedLock()  # Create a global instance of the lock


async def task(uid: int):
    async with NAMED_LOCKS.lock(uid):  # Lock on some name
        print(f"Task {uid} started")
        # do something
        await asyncio.sleep(uniform(1, 5))
        print(f"Task {uid} finished")


async def main():
    tasks = [asyncio.create_task(task(uid)) for uid in [randint(1, 10) for _ in range(50)]]
    await asyncio.gather(*tasks)


asyncio.run(main())

Metadata

Release files for namedlocks 0.0.1a3

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

Source distribution (sdist)

Source distribution for namedlocks 0.0.1a3
File Size Uploaded Provenance Actions
namedlocks-0.0.1a3.tar.gz 2.7 kB Without provenance Details for namedlocks-0.0.1a3.tar.gz

Built distribution (wheel)

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

Total release size: 8.0 kB

Release files / namedlocks-0.0.1a3.tar.gz

Download URL namedlocks-0.0.1a3.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0d7492230e20ac359444fbad2625b7d6b6ba204fdcea3154d7a7962cd713d55d
BLAKE2b-256 checksum
How to use checksums
ad6aed9d1f507ff167d1f9fda967e41e82922ac5c0161d2d3a23f698301f9da3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release files / namedlocks-0.0.1a3-py3-none-any.whl

Download URL namedlocks-0.0.1a3-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0654dd91da640211f226cbe1fbeb1fe5bfd66c3626666e730cbea6cb0b6c1366
BLAKE2b-256 checksum
How to use checksums
4e3798397ffecd8974bd383f46b02d3032270417c98d9421608400c232641835
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Security for namedlocks 0.0.1a3

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.

Release history Release notifications | RSS feed

This release
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