MCPcopy Create free account
hub / github.com/Mercury7353/PyBench / __enter__

Method __enter__

llms/api_key_pool.py:213–221  ·  view source on GitHub ↗

Get a client from the pool and return it as a context manager.

(self, **kwargs)

Source from the content-addressed store, hash-verified

211 heapify(self.queue)
212
213 def __enter__(self, **kwargs) -> ClientArgs:
214 """Get a client from the pool and return it as a context manager."""
215
216 if len(self) == 0:
217 raise APIKeyPoolEmptyError("api key pool is empty")
218
219 self._cur_resource = heappop(self.queue)
220
221 return self._cur_resource.client_args
222
223 def __exit__(self, exc_type, exc_value, exc_traceback) -> bool:
224 """Put the resource back in the pool."""

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected