RabbitMQ broker implementation for PATIO
Project description
PATIO Rabbitmq
PATIO is an acronym for Python Asynchronous Task for AsyncIO.
This package provides RabbitMQ broker implementation.
Example
Task executor
import asyncio
import operator
from functools import reduce
from patio import Registry, ThreadPoolExecutor
from patio_rabbitmq import RabbitMQBroker
rpc = Registry(project="patio-rabbitmq", auto_naming=False)
@rpc("mul")
def mul(*args):
return reduce(operator.mul, args)
async def main():
async with ThreadPoolExecutor(rpc, max_workers=16) as executor:
async with RabbitMQBroker(
executor, amqp_url="amqp://guest:guest@localhost/",
) as broker:
await broker.join()
if __name__ == "__main__":
asyncio.run(main())
Task producer
import asyncio
from patio import NullExecutor, Registry
from patio_rabbitmq import RabbitMQBroker
async def main():
async with NullExecutor(Registry(project="patio-rabbitmq")) as executor:
async with RabbitMQBroker(
executor, amqp_url="amqp://guest:guest@localhost/",
) as broker:
print(
await asyncio.gather(
*[
broker.call("mul", i, i, timeout=1) for i in range(10)
]
),
)
if __name__ == "__main__":
asyncio.run(main())
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
patio_rabbitmq-0.1.1.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for patio_rabbitmq-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e9172704adb921fe3167d6fe3fb46f00af59637e38d66c95deca033a7b2fa34 |
|
MD5 | 7729ec2c8c97bea47c4271a8599f6f76 |
|
BLAKE2b-256 | 49076c77b0492556eb6f63b3f72adee5279d69d43f8226b64262952dbc3d7c10 |