Pika-wrapper
Project description
from pika.spec import BasicProperties
Pikados
Pikados is a wrapper around Pika, providing a more asyncio-compatible syntax for channels and connections. An effort is made to keep the syntax close to Pika, but simply provide async functions as many developers expect.
Usage
Pikados still uses Pika's AsyncioConnection internally.
Pika is very clever with its usage of callbacks,
allowing its implementation to start a connection with its' #!python __init__ implementation.
import asyncio
from pika import URLParameters, BasicProperties
from pika.spec import Basic
from pikados.channel import AsyncChannel
from pikados.connection import connect, AsyncConnection
url = URLParameters("amqp://guest:guest@localhost:5672/%2F")
def on_message(channel: AsyncChannel, method: Basic.Deliver, properties: BasicProperties, body: bytes):
# Force it to be synchronous (errors will go unseen)
channel.base.basic_ack(method.delivery_tag)
# coro = my_handler(channel, method, properties, body)
# asyncio.get_running_loop().create_task(coro)
# ... await channel.basic_ack(method.delivery_tag)
async def main():
con: AsyncConnection = await connect(url, 'MyApp')
channel = await con.channel()
await channel.basic_qos(prefetch_count=1)
await channel.basic_consume(
'queue',
on_message_callback=on_message,
auto_ack=False,
)
await con.closed.wait()
Docs
Please install using requirements-docs.txt and run using mkdocs serve.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pikados-0.1.1.tar.gz.
File metadata
- Download URL: pikados-0.1.1.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ed75f6efa3215a40afcace2396159e46fa8c99f7a7105ddc841c9c42407cd5d
|
|
| MD5 |
ab3d2585a7f2cd0caddf7d5e3b397053
|
|
| BLAKE2b-256 |
87f69a2dd62ed883f3e4f48eb92a9837becd9f5ac4e1b13024c6f48842031794
|
File details
Details for the file pikados-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pikados-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66d2bf8ad7702a1bf7e7d5e6fb6e6efcb16e18f9084444f3343ed5fed0e82831
|
|
| MD5 |
775c1cd6ec8d3220fe85721cee805bf0
|
|
| BLAKE2b-256 |
0ccd09ff7a5f016eda56d4da0adfd2b718f05748ea4747dd34f1736243b88b98
|