Skip to content

DocumentIntelligenceClient.begin_analyze_document and poller.result() block event loop despite async API #42152

@danielbkang

Description

@danielbkang
  • Package Name: azure-ai-documentintelligence
  • Package Version: 1.0.0 - 1.0.2
  • Operating System: Windows 11, Linux (Azure Functions Python 4.x Docker base image)
  • Python Version: Python 3.11

Describe the bug
The begin_analyze_document method of DocumentIntelligenceClient (from the async azure.ai.documentintelligence.aio package) and its returned poller’s result() method perform blocking I/O internally. Despite being part of the async SDK, these calls block the asyncio event loop, causing delays and concurrency issues in frameworks like FastAPI.

To Reproduce
Steps to reproduce the behavior:

  1. Use DocumentIntelligenceClient from azure.ai.documentintelligence.aio in an async FastAPI endpoint.
  2. Call await client.begin_analyze_document(...).
  3. Await poller.result().
  4. Observe that the FastAPI event loop is blocked during the call, causing other requests to stall.

Expected behavior
Both begin_analyze_document and poller.result() should perform non-blocking async I/O, allowing other asyncio tasks to run concurrently without delay.

Screenshots
N/A

Additional context
As a temporary workaround, offloading the blocking calls to a thread using asyncio.to_thread() avoids event loop blocking.

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Document Intelligencecustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions