hyb
2026-01-09 4cb426cb3ae31e772a09d4ade5b2f0242aaeefa0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from typing import TYPE_CHECKING
 
if TYPE_CHECKING:
    from redis.asyncio.client import Pipeline, Redis
 
 
def from_url(url, **kwargs):
    """
    Returns an active Redis client generated from the given database URL.
 
    Will attempt to extract the database id from the path url fragment, if
    none is provided.
    """
    from redis.asyncio.client import Redis
 
    return Redis.from_url(url, **kwargs)
 
 
class pipeline:  # noqa: N801
    def __init__(self, redis_obj: "Redis"):
        self.p: "Pipeline" = redis_obj.pipeline()
 
    async def __aenter__(self) -> "Pipeline":
        return self.p
 
    async def __aexit__(self, exc_type, exc_value, traceback):
        await self.p.execute()
        del self.p