Skip to main content

Redis broker implementation for PATIO

Project description

PyPI - License Wheel Mypy PyPI PyPI Coverage Status tox

PATIO Redis

PATIO is an acronym for Python Asynchronous Task for AsyncIO.

This package provides Redis broker implementation.

Example

Worker

import asyncio
import operator
from functools import reduce

from patio import Registry, ThreadPoolExecutor

from patio_redis import RedisBroker


rpc = Registry(project="test", strict=True)


@rpc("mul")
def mul(*args):
    return reduce(operator.mul, args)


async def main():
    async with ThreadPoolExecutor(rpc, max_workers=16) as executor:
        async with RedisBroker(
            executor, url="redis://127.0.0.1:6379", max_connections=50,
        ) as broker:
            await broker.join()


if __name__ == "__main__":
    asyncio.run(main())

Producer

import asyncio

from patio import NullExecutor, Registry

from patio_redis import RedisBroker


rpc = Registry(project="test", strict=True)


async def main():
    async with NullExecutor(rpc) as executor:
        async with RedisBroker(
            executor, url="redis://127.0.0.1/", max_connections=50,
        ) as broker:
            for i in range(50):
                print(
                    await asyncio.gather(
                        *[
                            broker.call("mul", i, j, timeout=1)
                            for j in range(200)
                        ]
                    ),
                )


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_redis-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

patio_redis-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file patio_redis-0.1.1.tar.gz.

File metadata

  • Download URL: patio_redis-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 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_redis-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6658d459bf1f81baa25012b143bedacd26fa0ca85c7a8d1ee97312ae1ad0b85f
MD5 0d3c89e7993cdb098cf108474279aae2
BLAKE2b-256 0bcd103b03eca157939f931fffa6e199680afe03ca0c2dacc94c246c26447450

See more details on using hashes here.

File details

Details for the file patio_redis-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: patio_redis-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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_redis-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60fc72f16f5bb10ea4bf92e5737948200e8ec4cf8927270e2ddd98cbee1e5845
MD5 74a4b91ca0d981bfa8140381b37e4a66
BLAKE2b-256 986979be52004b04dcf3f091f0ada24a7ffdb5d7891e92320ff4a9ee1dd81847

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