Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Async method get_alias from SearchIndexClient is blocking operation #39388

Open
Chotom opened this issue Jan 24, 2025 · 3 comments
Open
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search

Comments

@Chotom
Copy link

Chotom commented Jan 24, 2025

  • 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:

  1. Set asyncio in debug mode by declaring env: PYTHONASYNCIODEBUG=1
  2. 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.

@github-actions github-actions bot added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search labels Jan 24, 2025
Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@xiangyan99
Copy link
Member

Thanks for reaching out.

I checked the call chain of the method and did not find we used blocking calls for requests.

Could you provide more details?

@xiangyan99 xiangyan99 added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Jan 24, 2025
Copy link

Hi @Chotom. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search
Projects
None yet
Development

No branches or pull requests

2 participants