easyrabbit
Actually easy RabbitMQ utilities for common tasks. Hides the complexities of complete control packages like pika by wrapping common use cases in minimalistic wrappers.
Installation
You can install directly from Pypi:
pip install easyrabbit
or from git using pip:
pip install git+https://github.com/scnerd/easyrabbit
Usage
Simple routing
Reader
RoutingReader provides a fully asynchronous way to read from an exchange via a queue bound with a routing key. It launches a subprocess to free the calling program from being responsible for its computational overhead; within its own process, it uses pika’s asynchronous connection, enabling the highest possible performance client. The API exposed mimics a simple queue, if, after all, what you really want is to use a RabbitMQ queue as if it were a Python queue.
with RoutingReader(url, exchange, queue_name, routing_key) as reader:
for msg in reader:
print("Received the following message: {}".format(msg))
If the reader is needed persistently, you can also launch and terminate it yourself:
reader = RoutingReader(url, exchange, queue_name, routing_key)
reader.start()
# Do things with the reader
reader.close()
Note that even though the reader is asynchronous, you don’t need to wait for it to be ready before using it. All calls hang on the process pipe that sends data from the client process to your parent code. If you want to make sure that the connection is fully established before using it, however, you can use wait_till_ready:
reader = RoutingReader(url, exchange, queue_name, routing_key)
reader.start()
try:
reader.wait_till_ready(timeout=5)
except TimeoutError:
raise RuntimeError("RabbitMQ reader took more than 5 seconds to launch")
While reader.get is blocking, a non-blocking equivalent is reader.get_nowait, or your code can explicitly check that a value is available first using not reader.empty(). Iterating over reader just repeatedly calls get, and hence is blocking and will only end when the reader is closed. Use reader.getall_nowait() to obtain all values currently in the queue.
All result objects are byte arrays.
Writing
The analogous utility for writing is RoutingWriter, which provides a nearly identical interface for writing messages to RabbitMQ
with RoutingWriter(url, exchange, routing_key) as writer:
for msg in msgs:
writer.put(msg)
RoutingWriter exposes much the same API as RoutingReader, except of course exposing put instead of get.
Metadata
Release files for easyrabbit 0.0.3
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 | |
|---|---|---|---|---|
| easyrabbit-0.0.3.tar.gz | 5.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easyrabbit-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / easyrabbit-0.0.3.tar.gz
| Download URL | easyrabbit-0.0.3.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c719d1b23f95bf33072eebb6c1f0a8e9763293f60da6298ba5b6142b4cd2b3e
|
|
BLAKE2b-256 checksum How to use checksums |
3468224d7fabdaf78dd00eacc1d33ee12d1be84c25b24a7d779928ea7a7501be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / easyrabbit-0.0.3-py3-none-any.whl
| Download URL | easyrabbit-0.0.3-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9415c6a1af8aadff1541ed917fc45c3733ab90e35926abad67f05dbb172a9a72
|
|
BLAKE2b-256 checksum How to use checksums |
c0b0ad7c7b57ca25919a16d70fa31d373646ba450f023589efde66e97e07206d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for easyrabbit 0.0.3
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.