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'
]
})
enqueue('TESTCHAN_1', 'my_package.my_module.func_name')
enqueue('TESTCHAN_2', 'my_package.my_module.func_name', '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
Close
Hashes for daemonless_queuing-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3490cb8b3fc82cfadedc8f2de8cf766c0d0d918acce30550dc2b5525b53dbcb4 |
|
MD5 | d540b8553b55151a999c03840a008fd7 |
|
BLAKE2b-256 | fb271ed619fcce5da91e9ec878b92133b26ca2b3559cafb0c1cdbc04964c4f6e |