Skip to main content

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


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.0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

patio_rabbitmq-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file patio_rabbitmq-0.1.0.tar.gz.

File metadata

  • Download URL: patio_rabbitmq-0.1.0.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.2 Darwin/22.4.0

File hashes

Hashes for patio_rabbitmq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5f2e19dda79ddd65e354b81fa9f71d86bfaeb48deae6913b79eea852a827c0f
MD5 825e56db181ab89ea897a947c855fc39
BLAKE2b-256 1b1d8690789ede166e61c77205fbe9c7852a80e97b8eb09b1cc029302865b9b6

See more details on using hashes here.

File details

Details for the file patio_rabbitmq-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: patio_rabbitmq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.2 Darwin/22.4.0

File hashes

Hashes for patio_rabbitmq-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b40dfa03524c6b2234b8a79c6eef285ae12128a4066766b7cbf327bffc5545b
MD5 8b1d20fe3cde6e2e857c16da2ff67d9e
BLAKE2b-256 3a2092e07cfeb0466ae788877d3e9812cf26a2b4f4f6eaf0ac52cc6d034e939d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page