redis-extending-lock 1.0.4

Creator: railscoderz

Last updated:

Add to Cart

Description:

redisextendinglock 1.0.4

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







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.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.