dumblock-0.1
توضیحات
redis lock decorators for django
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX :: Linux |
| نام فایل | dumblock-0.1 |
| نام | dumblock |
| نسخه کتابخانه | 0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Roman Evstifeev |
| ایمیل نویسنده | someuniquename@gmail.com |
| آدرس صفحه اصلی | https://github.com/Fak3/dumblock |
| آدرس اینترنتی | https://pypi.org/project/dumblock/ |
| مجوز | MIT |
This package provides decorators that will try to acquire redis lock
before calling decorated function.
Installation
------------
.. code:: bash
pip install dumblock
Usage
-----
Set ``DUMBLOCK_REDIS_URL`` in your django settings:
.. code:: python
DUMBLOCK_REDIS_URL = "redis://localhost:6379"
lock\_or\_exit
~~~~~~~~~~~~~~
Decorator. Before decorated function starts, try to acquire redis lock
with specified key. If lock is acquired successfully, proceed executing
the function. Otherwise, return immediately. The ``key`` argument can
contain templated string, wich will be rendered with args and kwargs,
passed to the function.
Example:
.. code:: python
@lock_or_exit('lock_work_{}')
def workwork(x):
pass
workwork(3) # Will try to acquire redis lock 'lock_work_3'
lock\_wait
~~~~~~~~~~
Decorator. Before decorated function starts, try to acquire redis lock
with specified key, waiting for ``waittime`` seconds if needed. If lock
is acquired successfully, proceed executing the function. Otherwise,
raise ``dumblock.TimeoutError``. The ``key`` argument can contain
templated string, wich will be rendered with args and kwargs, passed to
the function.
Example:
.. code:: python
@lock_wait('lock_work_{}', waittime=4)
def workwork(x):
pass
workwork(3) # Will try to acquire redis lock 'lock_work_3' for 4 seconds
نحوه نصب
نصب پکیج whl dumblock-0.1:
pip install dumblock-0.1.whl
نصب پکیج tar.gz dumblock-0.1:
pip install dumblock-0.1.tar.gz