Azure / Azure/azure-sdk-for-python

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

Offen
#42,152 18 Kommentare 5 Reaktionen 1 zugewiesene Person Beansprucht von @bojunehsu Auf GitHub ansehen
Client customer-reported Document Intelligence needs-team-attention question
Vorherrschende Sprache
Python
Sterne
5.6k
Forks
3.4k
Ø Merge
2 T. 2 Std.
Gemergte PRs (30 T.)
213

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.