Patio Rabbitmq 0.1.1 | Coderz Repository

patio-rabbitmq 0.1.1

Last updated:

0 purchases

patio-rabbitmq 0.1.1 Image
patio-rabbitmq 0.1.1 Images

Free

Languages

Categories

Add to Cart

Description:

patiorabbitmq 0.1.1

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())

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.