coro_with_context() — langchain Function Reference
Architecture documentation for the coro_with_context() function in utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 999edc6c_5944_34b9_f589_430c83786bff["coro_with_context()"] ca66092c_447c_d201_0d3c_cfa6ca2cc9d3["utils.py"] 999edc6c_5944_34b9_f589_430c83786bff -->|defined in| ca66092c_447c_d201_0d3c_cfa6ca2cc9d3 8d6aa7c7_9ea2_4168_d8f3_f753a332b582["asyncio_accepts_context()"] 999edc6c_5944_34b9_f589_430c83786bff -->|calls| 8d6aa7c7_9ea2_4168_d8f3_f753a332b582 style 999edc6c_5944_34b9_f589_430c83786bff fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/runnables/utils.py lines 138–155
def coro_with_context(
coro: Awaitable[_T], context: Context, *, create_task: bool = False
) -> Awaitable[_T]:
"""Await a coroutine with a context.
Args:
coro: The coroutine to await.
context: The context to use.
create_task: Whether to create a task.
Returns:
The coroutine with the context.
"""
if asyncio_accepts_context():
return asyncio.create_task(coro, context=context) # type: ignore[arg-type,call-arg,unused-ignore]
if create_task:
return asyncio.create_task(coro) # type: ignore[arg-type]
return coro
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does coro_with_context() do?
coro_with_context() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/utils.py.
Where is coro_with_context() defined?
coro_with_context() is defined in libs/core/langchain_core/runnables/utils.py at line 138.
What does coro_with_context() call?
coro_with_context() calls 1 function(s): asyncio_accepts_context.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free