Skip to main content

Distributed lock library using nats.py

Project description

natspy-lock

PyPI - Version PyPI - Python Version


natspy-lock is a distributed lock library using nats.

Table of Contents

Installation

pip install natspy-lock

Example

import nats
from natspy_lock import NatsLock

async def main():
    nc = await nats.connect("nats://127.0.0.1:4222")
    await NatsLock.init(nc.jetstream(), "test_lock", 60)
    async with NatsLock.get_lock("test_lock", 1):
    #     do something
        pass
    await nc.drain()

License

natspy-lock is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

natspy_lock-0.2.0.tar.gz (6.7 kB view hashes)

Uploaded Source

Built Distribution

natspy_lock-0.2.0-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page