igorbenav / fastcrud

FastCRUD is a Python package for FastAPI, offering robust async CRUD operations and flexible endpoint creation utilities.
MIT License
693 stars 59 forks source link

Redis client is not initialized in Rate Limiter utils #159

Closed scottyeung closed 2 months ago

scottyeung commented 2 months ago

Describe the bug or question A clear and concise description of what the bug or question is.

To Reproduce Please provide a self-contained, minimal, and reproducible example of your use case

async def is_rate_limited(db: AsyncSession, user_id: int, path: str, limit: int, period: int) -> bool:
    if client is None:
        logger.error("Redis client is not initialized.")
        raise Exception("Redis client is not initialized.")

Description Redis client was recognised as none when I tried to create background tasks in Swagger and caught exception in is_rate_limited

Screenshots

Screenshot 2024-09-08 at 5 12 24 PM Screenshot 2024-09-08 at 5 12 36 PM Screenshot 2024-09-08 at 5 14 44 PM

Additional context Add any other context about the problem here.