MCPcopy
hub / github.com/redis/redis-py / __aenter__

Method __aenter__

redis/asyncio/client.py:688–701  ·  view source on GitHub ↗

Async context manager entry. Increments a usage counter so that the connection pool is only closed (via aclose()) when no context is using the client.

(self: _RedisT)

Source from the content-addressed store, hash-verified

686 )
687
688 async def __aenter__(self: _RedisT) -> _RedisT:
689 """
690 Async context manager entry. Increments a usage counter so that the
691 connection pool is only closed (via aclose()) when no context is using
692 the client.
693 """
694 await self._increment_usage()
695 try:
696 # Initialize the client (i.e. establish connection, etc.)
697 return await self.initialize()
698 except Exception:
699 # If initialization fails, decrement the counter to keep it in sync
700 await self._decrement_usage()
701 raise
702
703 async def _increment_usage(self) -> int:
704 """

Callers

nothing calls this directly

Calls 3

_increment_usageMethod · 0.95
initializeMethod · 0.95
_decrement_usageMethod · 0.95

Tested by

no test coverage detected