PATIO的Redis代理实现
项目描述
PATIO Redis
PATIO是Python异步Task for AsyncIO的缩写。
此软件包提供Redis代理实现。
示例
工作线程
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())
生产者
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())
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装软件包的更多信息。
源代码分发
patio_redis-0.1.1.tar.gz (3.8 kB 查看哈希)
构建分发
patio_redis-0.1.1-py3-none-any.whl (4.6 kB 查看哈希)