aclosing#
- class langchain_core.utils.aiter.aclosing(thing: AsyncGenerator[Any, Any] | AsyncIterator[Any])[source]#
异步上下文管理器,用于安全地完成异步清理的资源,例如异步生成器,调用其
aclose()
方法。代码如下:
- async with aclosing(<module>.fetch(<arguments>)) as agen:
等同于以下内容:
agen =
.fetch( ) 尝试: - finally:
等待 agen.aclose()
方法
__init__
(thing)- Parameters:
thing (AsyncGenerator[Any, Any] | AsyncIterator[Any])