Put the resource back in the pool.
(self, exc_type, exc_value, exc_traceback)
| 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.""" |
| 225 | |
| 226 | # TODO how to update the usage? |
| 227 | self._cur_usage = { |
| 228 | "prompt_tokens": 0, |
| 229 | "completion_tokens": 0, |
| 230 | "total_tokens": 0, |
| 231 | } |
| 232 | heappush(self.queue, self._cur_resource.update(self._cur_usage)) |
| 233 | if exc_type is not None: |
| 234 | # Log the exception or handle it as needed |
| 235 | logger.error(f"Client Pool Error: {exc_type}, {exc_value}") |
| 236 | return False |
| 237 | return True |
| 238 | |
| 239 | |
| 240 | class RandomPool(Pool): |