Observed since 21 Oct, 11:42 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Asyncio compatible wraper around the aio-pika library for consumining messages.
An asyncio compatible wrapper around aio-pika that brings the follwoing advantages:
pip install aio-bunny
In the simplest form, you can do the following to spin up a consumer:
import asyncio
from aio_bunny import Bunny
async def main():
bunny = Bunny("amqp://guest:guest@127.0.0.1/")
@bunny.consumer(
queue="myqueue",
exchange="myexchange",
routing_key="key")
async def on_message(msg: bytes):
await asyncio.sleep(1)
print('received:', msg.decode())
await bunny.start()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
To shutdown the consumers gracefully, all you need to do is to call the stop method on the Bunny instance.
This method will stop the consumer from accepting new messages from the broker, waits for all inflight tasks to finish and exits cleanly.\
So In the following example, we want to stop the application whenever SIGINT OR SIGTERM is received:
import asyncio
import signal
from aio_bunny import Bunny
async def main():
bunny = Bunny("amqp://guest:guest@127.0.0.1/")
async def shutdown(signal, loop):
print(f"Received exit signal: {signal.name}")
await bunny.stop() # Stopping the consumers here
loop.stop()
loop = asyncio.get_event_loop()
# Call the shutdown funciton on any of these signals.
signals = (signal.SIGTERM, signal.SIGINT)
for s in signals:
loop.add_signal_handler(s, lambda s=s: asyncio.create_task(shutdown(s, loop)))
@bunny.consumer(
queue="myqueue",
exchange="myexchange",
routing_key="key")
async def on_message(msg: bytes):
await asyncio.sleep(1)
print('received:', msg.decode())
await bunny.start()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()
This software follows Semantic Versioning
Clone the project:
git clone repo_url
cd aio-bunny
Create a virtualenv for aio-bunny:
python3 -m venv venv
source venv/bin/activate
Install the requirements:
pip install -e '.[develop]'
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.0.3 | 17 Jul 2024 | 14 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 11:42 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:726f29560956dd36a2cff7a080565034a55d53425dd7e05b35c035b2317c32ca