Registry / database / aiormq

aiormq

JSON →
library7.0.0pypypi✓ verified 26d ago

aiormq is a pure Python asynchronous client library for the AMQP 0.9.1 protocol, commonly used for interacting with RabbitMQ. It provides a non-blocking interface leveraging `asyncio`. The current version is 6.9.4, and it maintains a steady release cadence with frequent patch and minor updates addressing bug fixes and performance improvements.

pip install aiormq
INSTALL
IMPORT
SIG · AIORMQ
A
aiormq
databasepythonv7.0.0
Install
2.7s avg
Import
351ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v6.9.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.360s · 20.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.7s · import 0.342s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

connect
from aiormq import connect
Channel
from aiormq.abc import Channel
While Channel is part of the internal structure, for type hinting, import from `aiormq.abc`.
IncomingMessage
from aiormq.abc import IncomingMessage
Required for type hinting message callbacks during consumption.

This quickstart demonstrates how to connect to an AMQP broker (like RabbitMQ), declare a queue, publish a message, and consume messages asynchronously. It uses `os.environ.get` for the AMQP URL, making it easy to configure without hardcoding credentials. Remember to have a RabbitMQ instance running at `localhost:5672` or specify a different `AMQP_URL`.

import asyncio import os from aiormq import connect from aiormq.abc import IncomingMessage # Get AMQP URL from environment variable, default to local RabbitMQ AMQP_URL = os.environ.get('AMQP_URL', 'amqp://guest:guest@localhost/') QUEUE_NAME = 'aiormq_test_queue' async def on_message(message: IncomingMessage): """Callback for consuming messages.""" print(f"[x] Received: {message.body.decode()}") await message.ack() # Acknowledge the message async def main(): connection = None try: # Establish connection print(f"[*] Connecting to {AMQP_URL}...") connection = await connect(AMQP_URL) print("[*] Connection established.") # Create a channel channel = await connection.channel() print("[*] Channel created.") # Declare a queue (idempotent operation) await channel.queue_declare(QUEUE_NAME) print(f"[*] Queue '{QUEUE_NAME}' declared.") # Publish a message message_body = b"Hello, aiormq world!" await channel.basic_publish( exchange='', routing_key=QUEUE_NAME, body=message_body ) print(f"[x] Published message: '{message_body.decode()}'") # Start consuming messages consumer_tag = await channel.basic_consume(QUEUE_NAME, on_message) print(f"[*] Consuming from '{QUEUE_NAME}'. Consumer tag: {consumer_tag}") # Keep the consumer running for a short period (e.g., 5 seconds) print("[*] Waiting for messages... Press Ctrl+C to exit") await asyncio.sleep(5) # Stop consuming await channel.basic_cancel(consumer_tag) print(f"[*] Consumer '{consumer_tag}' cancelled.") except Exception as e: print(f"[!] An error occurred: {e}") finally: if connection: print("[*] Closing connection...") await connection.close() print("[*] Connection closed.") if __name__ == '__main__': asyncio.run(main())
Debug
Known issues
breakingPython 3.7 support was dropped in aiormq version 6.8.0. If you are using Python 3.7, you must upgrade your Python version or pin `aiormq<6.8.0`.
fix
Upgrade to Python 3.8+ or pin `aiormq` to a version less than 6.8.0 in your `requirements.txt`.
affects: >=6.8.0
gotchaProperly closing connections and channels is crucial in asynchronous applications to prevent resource leaks and ensure graceful shutdown. Failing to `await connection.close()` and `await channel.close()` can lead to hung connections or unreleased resources.
fix
Always wrap your AMQP operations in `try...finally` blocks to ensure `await connection.close()` and `await channel.close()` are called, even if exceptions occur. For channels, ensure they are closed before the connection.
affects: All
gotchaWhile `aiormq` aims to handle AMQP URLs robustly, be mindful of special characters, complex VHosts, or non-standard query parameters in your connection string. Historically, there have been minor fixes related to URL parsing (e.g., slash unquoting in 6.8.1).
fix
Ensure your AMQP connection URL is properly URL-encoded, especially for parts like VHosts or usernames/passwords that might contain special characters. Test complex URLs thoroughly.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aiormq'
The 'aiormq' package is not installed in the Python environment.
fix
Install the package using pip: 'pip install aiormq'.
ImportError: cannot import name 'connect' from 'aiormq'
The 'connect' function does not exist in the 'aiormq' module.
fix
Use 'from aiormq import Connection' and then 'connection = await Connection.connect()'.
AttributeError: module 'aiormq' has no attribute 'Channel'
The 'Channel' class is not directly accessible from the 'aiormq' module.
fix
Access the 'Channel' class through an established connection: 'channel = await connection.channel()'.
TypeError: 'NoneType' object is not callable
Attempting to call a method on a 'None' object, possibly due to a failed connection.
fix
Ensure the connection is successfully established before calling methods: 'connection = await aiormq.connect()'.
RuntimeError: Event loop is closed
The asyncio event loop has been closed before the asynchronous operation could complete.
fix
Ensure the event loop is running when performing asynchronous operations: 'asyncio.run(main())'.
Upgrade
Version history
7.0.0latest on PyPI · released Jul 9, 2026
Audit
Dependencies
pamqprequiredCore dependency for AMQP 0.9.1 protocol framing.
Agent activity
48 hits · last 30 days
node
42
OpenAI (training)
2
Resources
aiormq — pip install aiormq · libregistry