Questions tagged [aioredis]
28 questions
7
votes
1 answer
module 'aioredis' has no attribute 'create_redis'
Using python 3.6.12 and aioredis 2.0.0, asyncio 3.4.3
Tried to use the snippet from the aioredis for testing pub/sub:
import asyncio
import aioredis
async def reader(ch):
while (await ch.wait_message()):
msg = await ch.get_json()
…

Saligia
- 147
- 1
- 9
4
votes
2 answers
How to use asyncio and aioredis lock inside celery tasks?
Goal:
Possibility to run asyncio coroutines.
Correct celery behavior on exceptions and task retries.
Possibility to use aioredis lock.
So, how to run async tasks properly to achieve the goal?
What is RuntimeError: await wasn't used with future…

SH21
- 43
- 1
- 4
3
votes
1 answer
How to gracefully close aioredis pool in aiohttp server?
I create redis pool the following way:
async def create_redis_connection_pool(app) -> aioredis.Redis:
redis = aioredis.from_url(
"redis://localhost", encoding="utf-8", decode_responses=True, max_connections=10,
)
app["redis"] =…

Artiom Kozyrev
- 3,526
- 2
- 13
- 31
2
votes
1 answer
Difference between await Coroutine and await Task
On FastAPI, I have an endpoint that calls get_1 or get_2 coroutine function below.
get_1 uses await redis.get(key)
get_2 uses await asyncio.ensure_future(redis.get(key))
Is there any difference between the 2 functions in terms of functionality and…

Rocherlee
- 2,536
- 1
- 20
- 27
2
votes
0 answers
How to improve Request rate in Gunicorn
We tested fastAPI application with Guicorn with 20 workers, the code for which is below,
import json
from typing import List, Dict
from async_lru import alru_cache
from fastapi import FastAPI
import aioredis
REDIS_HOST: str = "localhost"
app:…

Prathiksha R
- 21
- 2
2
votes
2 answers
Asynchronous code failure when connecting to redis
I created a small class to perform basic operations with redis, using aioredis.
class RedisService:
def __init__(self, r_url) -> str:
self.redis = r_url
async def create_connection(self):
return await…

Jekson
- 2,892
- 8
- 44
- 79
1
vote
1 answer
redis lock acquiring not working - stays running and never acquires
this is my code:
pool = aioredis.ConnectionPool.from_url("redis://localhost:6379")
redis = await aioredis.Redis(connection_pool=pool, ssl=False, ssl_cert_reqs="None")
async with redis.lock("hello_lock") as lock:
print("hello")
await…

3awny
- 319
- 1
- 2
- 10
1
vote
1 answer
Has asyncio been removed from redis-py?
I'm currently working on setting up Redis with FastAPI. This is my first time using redis and in my attempt to find out whether it was possible to use redis asynchronously, I stumbled upon aioredis-py.
According to their documentation:
However, my…

2Clutch
- 129
- 10
1
vote
2 answers
Implement concurrent data fetch from Azure Redis cache in python
I am currently working on building low latency model inference API using fast API, we are using azure redis cache standard version for fetching features and onnx model for fast model inference. I am using aioredis to implement concurrency for data…

Mohammad Rijwan
- 335
- 3
- 17
1
vote
1 answer
grpc unary-stream with redis pubsub - degradation with too many clients
We have a python grpc (grpcio with asyncio) server which performs server side streaming of data consumed from redis PUB/SUB (using aioredis 2.x) , combining up to 25 channels per stream. With low traffic everything works fine, as soon as we reach…

mike_t
- 2,484
- 2
- 21
- 39
1
vote
0 answers
How to generate URI and connection for Azure Redis Service with aioredis-py
I am trying to switch from the official redis python package (redis-py) to the async equivalent aioredis-py package.
I currently connect using the official package with:
import redis
redis_client = redis.Redis(
host="abc",
port=6380,
…

Mysterio
- 2,878
- 2
- 15
- 21
1
vote
0 answers
I am getting this error: Task was destroyed but it is pending
from aioredis import (
create_redis_pool
)
class RedisConn:
def __init__(self):
self.conn = None
def set_conn(self, c):
self.conn = c
def get_conn(self):
return self.conn
rdpsc = RedisConn()
async def…

Kanav Raina
- 43
- 1
- 9
0
votes
0 answers
How to write data to aioredis with FastApi
I'm new to Redis, and I want to use aioredis in fastapi (write data to redis then get data)
The code and error result is following:
code
import asyncio
from redis import asyncio as aioredis
from fastapi import FastAPI
import uvicorn
app =…

Josh-money
- 21
- 2
0
votes
0 answers
pubsub.get_message() sometimes doesn't receive messages
Version: redis-py 4.5.1, redis-stack
Platform: Python 3.9.12 on Ubuntu 20.4
Description:
To give some context, I have a notifier that publishes a user_info dict in redis every time there is an update in a user. I can see this working fine using…

mari
- 1
0
votes
0 answers
My Bullmq working not running tasks for all jobs in the queue
I am running a background job to generate pdfs using puppeteer and i am emailing out these pdfs using recipients name and email. below is my worker logic
const sendCertificatesWorker = new Worker(
queueName,
async job => {
const {
data: { id, name,…