throw-catch
Small RabbitMQ helpers for publishing, receiving, and clearing JSON messages with minimal setup.
throw-catch is designed for lightweight workflows where you want to drop structured messages into a queue, fetch them back in tests or background jobs, and keep the API surface tiny.
Highlights
- Simple
throw,catch, andclearfunctions. - JSON serialization via
orjson. - Optional message tags for selective reads.
- Per-message TTL support in minutes.
- Works with Python
3.11+. - Managed with
uv.
Installation
uv add throw-catch
Quick Start
import os
from throw_catch import catch, clear, throw
amqp_uri = os.getenv("AMQP_URI")
throw(payload={"hello": "world"}, uri=amqp_uri)
messages = catch(uri=amqp_uri)
print(messages)
clear(uri=amqp_uri)
Usage
Publish messages
from throw_catch import throw
throw(
payload={"event": "user.created", "user_id": 42},
uri="amqp://guest:guest@localhost:5672/",
)
throw(
payload={"event": "invoice.ready"},
tag="billing",
routing_key="events.billing",
ttl=30,
uri="amqp://guest:guest@localhost:5672/",
)
Notes:
payloadmust be a non-empty dictionary.ttlis in minutes.ttl=0publishes without expiration.
Receive messages
from throw_catch import catch
messages = catch(
uri="amqp://guest:guest@localhost:5672/",
queue="events.billing",
tag="billing",
count=10,
)
catch returns a list of decoded message dictionaries and acknowledges only the messages it actually returns.
Clear a queue
from throw_catch import clear
clear(
uri="amqp://guest:guest@localhost:5672/",
queue="events.billing",
)
API
throw(payload, tag=None, uri=None, routing_key="throw_catch", ttl=180)
Publishes a message to the target queue.
catch(tag=None, uri=None, queue="throw_catch", count=1)
Reads up to count messages from the queue and returns them as a list.
clear(uri=None, queue="throw_catch")
Deletes the target queue.
Development
Install dependencies:
uv sync --dev
Run tests:
uv run pytest
Metadata
Release files for throw-catch 0.3.0
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 |
|---|---|---|---|---|
| throw_catch-0.3.0.tar.gz | 5.9 kB | Without provenance | Details for throw_catch-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| throw_catch-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for throw_catch-0.3.0-py3-none-any.whl |
Total release size: 10.7 kB
Release files / throw_catch-0.3.0.tar.gz
| Download URL | throw_catch-0.3.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab0e2eeacfaf71d9204a6996938aa3c56275f069a05677cb6c91240b12b9cac6
|
|
BLAKE2b-256 checksum How to use checksums |
201a70d50a237b32927990414a481c03a9b623f93c49051aef697c07d43e06ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / throw_catch-0.3.0-py3-none-any.whl
| Download URL | throw_catch-0.3.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c4914fa2433105687dcc2ff94033bbcafd227b5b0fb8c0879dabb1c6dcf59848
|
|
BLAKE2b-256 checksum How to use checksums |
92957cc11c54d3d82c903fed83317d9bda6efd94dabadeaf890d4dde73a69529
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for throw-catch 0.3.0
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.