()
| 560 | try: |
| 561 | # Batches are independent API round trips; issuing them serially |
| 562 | # meant 120 uncached texts took 126.5s. The OpenAI client is |
| 563 | # thread-safe and each cache entry is its own file, so the only |
| 564 | # shared state is the pre-sized results list, written by index. |
| 565 | workers = self._batch_concurrency(len(batches)) |
| 566 | if len(batches) > 1 and workers > 1: |
| 567 | with ThreadPoolExecutor(max_workers=workers) as executor: |
| 568 | batch_results = list(executor.map(embed_one_batch, batches)) |
| 569 | else: |
no test coverage detected