patio-redis 0.1.1

Creator: railscoder56

Last updated:

Add to Cart

Description:

patioredis 0.1.1

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

License

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

Customer Reviews

There are no reviews.