aclosing#

class langchain_core.utils.aiter.aclosing(thing: AsyncGenerator[Any, Any] | AsyncIterator[Any])[source]#

Async context manager for safely finalizing an asynchronously cleaned-up resource such as an async generator, calling its aclose() method.

Code like this:

async with aclosing(<module>.fetch(<arguments>)) as agen:

<block>

is equivalent to this:

agen = <module>.fetch(<arguments>) try:

<block>

finally:

await agen.aclose()

Methods

__init__(thing)

Parameters:

thing (AsyncGenerator[Any, Any] | AsyncIterator[Any])

__init__(thing: AsyncGenerator[Any, Any] | AsyncIterator[Any]) None[source]#
Parameters:

thing (AsyncGenerator[Any, Any] | AsyncIterator[Any])

Return type:

None