fix: enforce max_workers in LLMMetadataExtractor.run_async#11248
Open
etairl wants to merge 1 commit intodeepset-ai:mainfrom
Open
fix: enforce max_workers in LLMMetadataExtractor.run_async#11248etairl wants to merge 1 commit intodeepset-ai:mainfrom
etairl wants to merge 1 commit intodeepset-ai:mainfrom
Conversation
The asyncio.Semaphore intended to bound concurrent LLM calls was acquired once around the outer gather(...) call instead of inside each task, so max_workers had no effect in run_async and all batched LLM requests fired simultaneously. Move the semaphore acquisition into a per-task wrapper so the documented concurrency cap is honored.
|
@etairl is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LLMMetadataExtractor.run_asyncacquires itsasyncio.Semaphoreonce around the outergather(...)instead of inside each task, somax_workershas no effect and every prompt in a batch fires its LLM call simultaneously.__init__advertisesmax_workersas "the maximum number of requests that should be allowed to run concurrently when using therun_asyncmethod", so the current behavior silently breaks that contract and can blow up LLM-provider rate limits / connection pools on large batches.async with sem:into a per-task wrapper coroutine so the limit is actually enforced. Added a regression test that verifies peak in-flight calls stay<= max_workers.Before
After
Test plan
hatch run test:unit -k test_llm_metadata_extractorpasses (includes newtest_run_async_respects_max_workers).