gather_with_concurrency() — langchain Function Reference
Architecture documentation for the gather_with_concurrency() function in utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 68b5bc9e_7e1f_b0a3_02e4_e149e32711ae["gather_with_concurrency()"] ca66092c_447c_d201_0d3c_cfa6ca2cc9d3["utils.py"] 68b5bc9e_7e1f_b0a3_02e4_e149e32711ae -->|defined in| ca66092c_447c_d201_0d3c_cfa6ca2cc9d3 dfcca044_cfe7_25bf_db90_97c2b92175f9["gated_coro()"] 68b5bc9e_7e1f_b0a3_02e4_e149e32711ae -->|calls| dfcca044_cfe7_25bf_db90_97c2b92175f9 style 68b5bc9e_7e1f_b0a3_02e4_e149e32711ae fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/runnables/utils.py lines 63–78
async def gather_with_concurrency(n: int | None, *coros: Coroutine) -> list:
"""Gather coroutines with a limit on the number of concurrent coroutines.
Args:
n: The number of coroutines to run concurrently.
*coros: The coroutines to run.
Returns:
The results of the coroutines.
"""
if n is None:
return await asyncio.gather(*coros)
semaphore = asyncio.Semaphore(n)
return await asyncio.gather(*(gated_coro(semaphore, c) for c in coros))
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does gather_with_concurrency() do?
gather_with_concurrency() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/utils.py.
Where is gather_with_concurrency() defined?
gather_with_concurrency() is defined in libs/core/langchain_core/runnables/utils.py at line 63.
What does gather_with_concurrency() call?
gather_with_concurrency() calls 1 function(s): gated_coro.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free