langchain_core.utils.aiter.aclosing

class langchain_core.utils.aiter.aclosing(thing: Union[AsyncGenerator[Any, Any], AsyncIterator[Any]])[来源]

用于安全地终止异步清理的资源,如异步生成器,调用其aclose()方法的异步上下文管理器。

以下代码示例

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

<区块>

等同于以下代码

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

<区块>

finally

await agen.aclose()

方法

__init__(thing)

参数

thing (Union[AsyncGenerator[Any, Any], AsyncIterator[Any]]) –

__init__(thing: Union[AsyncGenerator[Any, Any], AsyncIterator[Any]]) None[来源]
参数

thing (Union[AsyncGenerator[Any, Any], AsyncIterator[Any]]) –

返回类型

None