Simple AMQP
A simple AMQP lib for Python
Installation
# Asyncio
pip install simple-amqp[asyncio]
# Gevent
pip install simple-amqp[gevent]
Example usage
# Asyncio
from asyncio import get_event_loop, sleep
from simple_amqp import AmqpMsg, AmqpParameters
from simple_amqp.asyncio import AsyncioAmqpConnection
conn = AsyncioAmqpConnection(AmqpParameters(host='localhost'))
channel = conn.channel()
exchange = channel.exchange('exchange.name', 'topic', durable=True)
async def msg_received(msg: AmqpMsg):
if msg.payload == b'ok':
return True # ack msg
return False # nack msg
channel \
.queue('queue.name', durable=True) \
.bind(exchange, 'topic.name') \
.consume(msg_received)
async def main():
await conn.start()
await channel.publish(AmqpMsg(
exchange='exchange.name',
topic='topic.name',
payload=b'ok',
))
await sleep(1)
await conn.stop()
loop = get_event_loop()
loop.run_until_complete(main)
# Gevent
from gevent import monkey
monkey.patch_all()
from time import sleep
from simple_amqp import AmqpMsg, AmqpParameters
from simple_amqp.gevent import GeventAmqpConnection
conn = GeventAmqpConnection(AmqpParameters(host='localhost'))
channel = conn.channel()
exchange = channel.exchange('exchange.name', 'topic', durable=True)
def msg_received(msg: AmqpMsg):
if msg.payload == b'ok':
return True # ack msg
return False # nack msg
channel \
.queue('queue.name', durable=True) \
.bind(exchange, 'topic.name') \
.consume(msg_received)
conn.start()
channel.publish(AmqpMsg(
exchange='exchange.name',
topic='topic.name',
payload=b'ok',
))
sleep(1)
conn.stop()
Metadata
Release files for simple-amqp 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_amqp-0.2.6-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for simple_amqp-0.2.6-py2.py3-none-any.whl |
Release files / simple_amqp-0.2.6-py2.py3-none-any.whl
| Download URL | simple_amqp-0.2.6-py2.py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
d553554c46e4fd99f9534e4db4f9dfaf8544afd4d0d3dcabf4680550593aed60
|
|
BLAKE2b-256 checksum How to use checksums |
5ceda71dbacdbce1fe29ef9d6e94395243aa330e27088a40f4cc51700fdf6453
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for simple-amqp 0.2.6
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.