Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
RabbitHole
✓ from rabbithole import RabbitHole
✗ from rabbit_hole import RabbitHole
Connect to RabbitMQ, declare a queue, publish and consume a message.
import os
from rabbit_hole import RabbitHole
# Initialize with environment variables or direct connection params
rh = RabbitHole(
host=os.environ.get('RABBIT_HOST', 'localhost'),
port=int(os.environ.get('RABBIT_PORT', 5672)),
username=os.environ.get('RABBIT_USER', 'guest'),
password=os.environ.get('RABBIT_PASS', 'guest')
)
# Declare a queue
rh.declare_queue('test_queue')
# Publish a message
rh.publish('test_queue', {'message': 'hello world'})
# Consume messages (callback)
def callback(ch, method, properties, body):
print(f"Received: {body}")
rh.ack(method.delivery_tag)
rh.consume('test_queue', callback=callback, auto_ack=False)
# Close connection
rh.close()
Debug
Known issues
breakingIn version 1.0.0, the library was renamed from 'gh-rabbit-hole' to 'rabbit_hole' for imports. The package name on PyPI remains 'gh-rabbit-hole'.fixUse 'from rabbit_hole import RabbitHole' instead of any old import path.
affects: <1.0.0 and >=1.0.0
deprecatedThe method 'consume' without auto_ack parameter defaults to False, but future versions may change default to True. Explicitly pass auto_ack to avoid breakage.fixAlways specify auto_ack=True or False explicitly when calling consume.
affects: 1.x
gotchaIf RabbitMQ is not running or connection fails, the library may hang indefinitely due to default timeout settings.fixSet timeout parameter explicitly, e.g., RabbitHole(..., timeout=5).
affects: all
gotchaThe 'publish' method expects a dict or string; passing other types may cause serialization errors.fixEnsure payload is a JSON-serializable dict or a string.
affects: all
Upgrade
Version history
1.6.0latest on PyPI · released Jan 1, 2024
Audit
Dependencies
pikarequiredCore dependency for RabbitMQ protocol