todo
Project description
Daemonless Queuing
Simple and reliable Redis queuing utilities.
Install
$ pip install daemonless-queuing
Usage
Queuing
import redis
from daemonless_queuing import setup, shutdown
instance = redis.Redis(
host='localhost',
port=6379
)
enqueue = setup(instance, {
'queues': [
'TESTCHAN_1',
'TESTCHAN_2'
]
})
# the third positional parameter is a integer (or None) representing the timeout in seconds
# after the timeout is reached the function subprocess will be killed
enqueue('TESTCHAN_1', 'my_package.my_module.func_name' 0)
enqueue('TESTCHAN_2', 'my_package.my_module.func_name', 0, 'positional argument', 42, named_arg='Hey!')
# ...
# do some blocking stuff
shutdown()
Locking
import redis
from daemonless_queuing import make_lock
instance = redis.Redis(
host='localhost',
port=6379
)
lock = make_lock(instance, 'SOMETHING_ONGOING')
with lock():
# will raise if you try to run this scope again before the lock gets released
...
Why?
I couldn't find a better suiting solution for what I needed (enqueuing stuff in multiple queues then running the jobs in parallel). Existing solutions (rq, Celery) are hard to setup and require a daemon/broker to work. Of course this is a much simpler version of these libraries, but some don't need more than that.
Caveats
- Functions must be provided as Python import paths
- Function parameters must be JSON-serializable
- Return values can't be accessed
Race condition
The function returned by make_lock is susceptible to race condition at the moment.
Make sure your asynchronous function won't be called twice at the same time.
License
This library is MIT licensed.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file daemonless_queuing-0.0.6.tar.gz.
File metadata
- Download URL: daemonless_queuing-0.0.6.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da105378931a1fb440bd38fae15f2bae673f2f53b9ec44440d6e633effaea9e1
|
|
| MD5 |
1ce3253120ee90a9928e79e582cef5a5
|
|
| BLAKE2b-256 |
049bb5a7d6dc5e4866f8c1b04c4de69d73032cb46c5ee0354f661fff171efc63
|
File details
Details for the file daemonless_queuing-0.0.6-py3-none-any.whl.
File metadata
- Download URL: daemonless_queuing-0.0.6-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd4efefd4cf66f15ed00341755dd9b7501b0e38c1dee8d88588d8f64ac1b4c9d
|
|
| MD5 |
a620e395c9716aa07cad3b6d4ec93263
|
|
| BLAKE2b-256 |
e9e4e62f26f48cb76eea44f601461782f2d622e8733fdcbb65175fcc99036349
|