Skip to content

Commit 7c198ea

Browse files
committed
fix: Add warning when max_workers is used with AsyncClient
Addresses Copilot review comment: AsyncClient silently ignores max_workers parameter. Now explicitly warns users that max_workers is not supported for async clients since asyncio.gather() manages concurrency automatically. The warning helps users understand why their max_workers setting isn't having the expected effect when using AsyncClient.
1 parent c2c3f3e commit 7c198ea

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/cohere/client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,17 @@ async def embed(
420420
effective_batch_size = batch_size if batch_size is not None else embed_batch_size
421421
texts_batches = [textsarr[i : i + effective_batch_size] for i in range(0, len(textsarr), effective_batch_size)]
422422

423-
# Note: max_workers parameter is not used in async version since asyncio.gather
423+
# Note: max_workers parameter is not applicable to async version since asyncio.gather
424424
# handles concurrency differently than ThreadPoolExecutor
425425
if max_workers is not None:
426-
# Log a warning or silently ignore - asyncio manages its own concurrency
427-
pass
426+
import warnings
427+
warnings.warn(
428+
"The 'max_workers' parameter is not supported for AsyncClient. "
429+
"Async clients use asyncio.gather() for concurrent execution, which "
430+
"automatically manages concurrency. The parameter will be ignored.",
431+
UserWarning,
432+
stacklevel=2
433+
)
428434

429435
responses = typing.cast(
430436
typing.List[EmbedResponse],

0 commit comments

Comments
 (0)