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)
| 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 | """ |
nothing calls this directly
no test coverage detected