Get a client from the pool and return it as a context manager.
(self, *args, **kwargs)
| 244 | logger.info(f"client args: {client_args}") |
| 245 | |
| 246 | def __enter__(self, *args, **kwargs) -> ClientArgs: |
| 247 | """Get a client from the pool and return it as a context manager.""" |
| 248 | |
| 249 | if len(self) == 0: |
| 250 | raise APIKeyPoolEmptyError("api key pool is empty") |
| 251 | |
| 252 | self._index = random.randint(0, len(self) - 1) |
| 253 | return self.queue[self._index].client_args |
| 254 | |
| 255 | def __exit__(self, exc_type, exc_value, exc_traceback) -> bool: |
| 256 | """Put the resource back in the pool.""" |
nothing calls this directly
no test coverage detected