[BUG] Async method get_alias from SearchIndexClient is blocking operation #39388
Open
Description
- Package Name: azure-search-documents
- Package Version: 11.6.0b9
- Operating System: MacOS Sequoia 15.2
- Python Version: Python 3.11
Describe the bug
The async method get_alias
from azure.search.documents.indexes.aio
module in the SearchIndexClient
class (link to method) seems to be the blocking operation. During the development of the asynchronous application, I've encountered the issue that calling the async version of get_alias
is blocking the asyncio loop. Despite being asynchronous the function calling takes between 200ms-500ms, which raise the warning from asyncio:
Executing <Task pending name='Task-3' coro=<func_to_test() running at ... created at /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py:825> took 0.287 seconds
Issue like this can lead to significant performance problems in any async application.
To Reproduce
Steps to reproduce the behavior:
- Set asyncio in debug mode by declaring env:
PYTHONASYNCIODEBUG=1
- Run below code:
import asyncio
from azure.identity.aio import EnvironmentCredential
from azure.search.documents.indexes.aio import SearchIndexClient
async def func_to_test():
"""This function should not block the event loop, but actually it is."""
async with (
EnvironmentCredential() as cred,
SearchIndexClient(AI_SEARCH_ENDPOINT, cred) as client,
):
ai_search_alias = await client.get_alias(ALIAS_NAME)
print(ai_search_alias)
asyncio.run(func_to_test())
Expected behavior
No single operation should block the loop and cause other tasks to be delayed or starved of execution time.
Metadata
Assignees
Labels
This issue points to a problem in the data-plane of the library.Issues that are reported by GitHub users external to the Azure organization.Workflow: More information is needed from author to address the issue.The issue doesn't require a change to the product in order to be resolved. Most issues start as that