This package provides decorators that will try to acquire redis lock before calling decorated function.
Installation
pip install dumblock
Usage
Set DUMBLOCK_REDIS_URL in your django settings:
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:
@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:
@lock_wait('lock_work_{}', waittime=4)
def workwork(x):
pass
workwork(3) # Will try to acquire redis lock 'lock_work_3' for 4 seconds
Metadata
Release files for dumblock 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dumblock-0.1.tar.gz | 2.4 kB | Without provenance | Details for dumblock-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dumblock-0.1-py3-none-any.whl | Python 3 | none | any | Details for dumblock-0.1-py3-none-any.whl |
Total release size: 6.6 kB
Release files / dumblock-0.1.tar.gz
| Download URL | dumblock-0.1.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a27af91b55706f54fb26036e058f3fe7fe2be3c7e882964d2ddecf14b09bda4
|
|
BLAKE2b-256 checksum How to use checksums |
30672466e7765750ba1ceae8ad270d9c41f191a36647bc685a4c6934e7d58b29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / dumblock-0.1-py3-none-any.whl
| Download URL | dumblock-0.1-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
84af2bf28140a42ffbb90fb2d64bbe8010a7c43cddefca6985c57c37facd0000
|
|
BLAKE2b-256 checksum How to use checksums |
29eb63dbd66897fe184f4c83cc4f405b4380b458abe6000f766a8ab05873291d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dumblock 0.1
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.