Skip to main content

Lock that prolongs itself from time to time and cancels current task if used as async context manager.

Coveralls Actions Latest Version https://img.shields.io/pypi/wheel/redis-extending-lock.svg https://img.shields.io/pypi/pyversions/redis-extending-lock.svg https://img.shields.io/pypi/l/redis-extending-lock.svg

Usage

import asyncio
import logging

from redis.asyncio import Redis
from redis_extending_lock import ExtendingLock


async def main():
    redis = Redis.from_url('redis://:hackme@localhost:6379/0')
    lock = ExtendingLock(
        redis, 'example',
        timeout=2,
        # optional, if not specified explicitly
        # would be half of timeout
        extend_interval=1,
        blocking_timeout=0,
    )

    async with lock:
        # your long-running task,
        # would be cancelled if lock would be not able to extend
        # for some reason
        await asyncio.Future()


logging.basicConfig(level=logging.DEBUG)
asyncio.run(main())

Lock can be also used without context manager:

import asyncio
import logging

from redis.asyncio import Redis
from redis_extending_lock import ExtendingLock


async def main():
    redis = Redis.from_url('redis://:hackme@localhost:6379/0')
    lock = ExtendingLock(
        redis, 'example', timeout=2, blocking_timeout=0,
    )
    await lock.acquire()
    await asyncio.sleep(5)
    await lock.release()


logging.basicConfig(level=logging.DEBUG)
asyncio.run(main())

How to develop

  • make devenv - configure the development environment

  • poetry shell or source .venv/bin/activate - activate virtualenv

  • make lint - syntax & code style check

  • make codestyle - reformat code

  • make test - test this project

  • make build - build this project

Versioning

This software follows Semantic Versioning.

Version is represented using MAJOR.MINOR.PATCH numbers, increment the:

  • MAJOR version when you make incompatible API changes

  • MINOR version when you add functionality in a backwards compatible manner

  • PATCH version when you make backwards compatible bug fixes

  • Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

In this case, the package version is assigned automatically with poem-plugins, it using on the tag in the repository as a major and minor and the counter, which takes the number of commits between tag to the head of branch.

Metadata

Release files for redis-extending-lock 1.0.4

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

Source distribution (sdist)

Source distribution for redis-extending-lock 1.0.4
File Size Uploaded Provenance Actions
redis_extending_lock-1.0.4.tar.gz 3.9 kB Without provenance Details for redis_extending_lock-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for redis-extending-lock 1.0.4
File Interpreter ABI Platform Actions
redis_extending_lock-1.0.4-py3-none-any.whl Python 3 none any Details for redis_extending_lock-1.0.4-py3-none-any.whl

Total release size: 8.2 kB

Release files / redis_extending_lock-1.0.4.tar.gz

Download URL redis_extending_lock-1.0.4.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5fd87aa0b13a7ae516ea32bd18431b4e734477fd45959a8eb402e442bf2cfb96
BLAKE2b-256 checksum
How to use checksums
2c52157c5b49184eaf363c1c76a44d8aededa2b72e8ef2fe8f10040a2120ce74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.9.16 Linux/5.15.0-1034-azure

Release files / redis_extending_lock-1.0.4-py3-none-any.whl

Download URL redis_extending_lock-1.0.4-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aff98c16e85a4cc78de29c66f84324fa21203bb5f6a856357314238386980abf
BLAKE2b-256 checksum
How to use checksums
c5203f085742ddf26c62893d9865d2c46150356273032d184c24eb25eccfa483
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.9.16 Linux/5.15.0-1034-azure

Security for redis-extending-lock 1.0.4

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