Azure / Azure/azure-sdk-for-python

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

Aperta
#42,152 18 commenti 5 reazioni 1 assegnatario Rivendicata da @bojunehsu Vedi su GitHub
Client customer-reported Document Intelligence needs-team-attention question
Lingua principale
Python
Stelle
5.6k
Fork
3.4k
Merge medio
2g
PR unite (30g)
217

Descrizione

- **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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.