langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
93.11k stars 14.97k forks source link

[Azure AI Search] RuntimeWarning: coroutine 'SearchClient.close' was never awaited #27097

Open nowjean opened 2 days ago

nowjean commented 2 days ago

Checked other resources

Example Code

The following code:

from langchain_community.vectorstores.azuresearch import AzureSearch
  vector_store: AzureSearch = AzureSearch(
            azure_search_endpoint=search_endpoint,
            azure_search_key=azure_search_key,
            azure_ad_access_token=None,
            index_name=index_name,
            embedding_function=aoai_embeddings.embed_query,
            semantic_configuration_name="lseSemanticConfig"
        )

Error Message and Stack Trace (if applicable)

it does RuntimeWarning: coroutine 'SearchClient.close' was never awaited loop.run_until_complete(self.async_client.close())

Description

I'm trying to using from langchain_community.vectorstores.azuresearch import AzureSearch

I expected to see no error or warning. Instead, it does RuntimeWarning: coroutine 'SearchClient.close' was never awaited loop.run_until_complete(self.async_client.close())

Normally, It's okay and working correctly, but when i concurrent request to my endpoint, i got this warnnig. Can i ignore this code or not?

System Info

System Information

OS: Linux OS Version: #49~20.04.1-Ubuntu SMP Wed Jul 12 12:44:56 UTC 2023 Python Version: 3.11.9 (main, Apr 6 2024, 17:59:24) [GCC 9.4.0]

Package Information

langchain_core: 0.3.0 langchain: 0.3.0 langchain_community: 0.3.0 langsmith: 0.1.129 langchain_openai: 0.2.0 langchain_text_splitters: 0.3.0 langgraph: Installed. No version info available.

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.9.5 async-timeout: Installed. No version info available. dataclasses-json: 0.6.7 httpx: 0.27.0 jsonpatch: 1.33 numpy: 1.26.4 openai: 1.44.0 orjson: 3.10.6 packaging: 24.1 pydantic: 2.8.2 pydantic-settings: 2.5.2 PyYAML: 6.0.1 requests: 2.32.3 SQLAlchemy: 2.0.31 tenacity: 8.5.0 tiktoken: 0.7.0 typing-extensions: 4.12.2

pokotylo commented 2 days ago

Probably related #24921