Ang-l / fastapi-template

:zap:快速生成fastapi模版
2 stars 1 forks source link

aioredis: TypeError: duplicate base class TimeoutError #19

Open terrapin-aurora opened 2 hours ago

terrapin-aurora commented 2 hours ago

python: 3.11 aioredis: 2.0.1

import aioredis

async def get_redis():    # redis

    redis_url = f"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}"

    redis = aioredis.from_url(redis_url, encoding="utf-8", decode_responses=True)

    try:
        yield redis
    finally:
        await redis.close()

Appears when using aioredis: TypeError: duplicate base class TimeoutError

Ang-l commented 2 hours ago

python: 3.11 aioredis: 2.0.1

import aioredis

async def get_redis():    # redis

    redis_url = f"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}"

    redis = aioredis.from_url(redis_url, encoding="utf-8", decode_responses=True)

    try:
        yield redis
    finally:
        await redis.close()

Appears when using aioredis: TypeError: duplicate base class TimeoutError

@terrapin-aurora The currently used Python 3 environment has not been updated from 3.6.8 to 3.11. We will upgrade the version to a new version and upgrade the corresponding dependency packages in the future. At present, the following methods can be used to temporarily solve the problem

pip install redis==4.5.5

from redis import asyncio as aioredis

async def get_redis():    # redis

    redis_url = "redis://[:password]@host:port[/database]"
    redis = aioredis.from_url(redis_url, encoding="utf-8", decode_responses=False, max_connections=30)

    try:
        yield redis
    finally:
        await redis.close()
terrapin-aurora commented 2 hours ago

Do you have any plans to upgrade to a new version in the near future. I am willing to assist with adjustments if needed