azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

`polling_interval` kwarg in DocumentIntelligenceClient.begin_analyze_document` is not being respected

Open aidangallagher4 opened this issue 1 year ago • 1 comments

  • Package Name: azure-ai-documentintelligence
  • Package Version: 1.0.2
  • Operating System: MacOS Sequoia 15.7
  • Python Version: 3.13.1

Describe the bug the polling_interval kwarg in DocumentIntelligenceClient.begin_analyze_document is not being respected

To Reproduce Steps to reproduce the behavior:

  1. run the following snippet
from io import BytesIO

from azure.ai.documentintelligence import DocumentIntelligenceClient
from azure.core.exceptions import HttpResponseError
from azure.core.polling import LROPoller

def run_ocr(pdf_bytes: bytes, client: DocumentIntelligenceClient) -> None
        poller: LROPoller = client.begin_analyze_document(
            model_id='prebuilt-read',
            body=BytesIO(pdf_bytes),
            content_type='application/pdf',
            output=['pdf'],
            polling_interval=10,
        )

        result = poller.result(timeout=timeout)
        if poller.status() != 'succeeded':
            raise Exception(f'Document intelligence failed with status {poller.status()}')

Expected behavior The poller should run every 10 seconds -- instead it polls every second. see the following stream of requests which was logged (note retry-after is always 1)

Request headers:
    'x-ms-client-request-id': 'adfbd91c-992a-11f0-a7a4-46532a3ca5f1'
    'User-Agent': 'azsdk-python-ai-documentintelligence/1.0.2 Python/3.10.15 (macOS-15.7-arm64-arm-64bit)'
    'Authorization': 'REDACTED'
No body was attached to the request

INFO:azure.core.pipeline.policies.http_logging_policy:Response status: 200
Response headers:
    'Content-Length': '106'
    'Content-Type': 'application/json; charset=utf-8'
    'retry-after': '1'
    'x-envoy-upstream-service-time': 'REDACTED'
    'apim-request-id': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'x-content-type-options': 'REDACTED'
    'x-ms-region': 'REDACTED'
    'Date': 'Wed, 24 Sep 2025 09:42:14 GMT'

INFO:azure.core.pipeline.policies.http_logging_policy:Request URL: 'https://DOMAIN.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-read/analyzeResults/8fd23bd0-5b6c-4573-8f69-099a0aa89a24?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'x-ms-client-request-id': 'adfbd91c-992a-11f0-a7a4-46532a3ca5f1'
    'User-Agent': 'azsdk-python-ai-documentintelligence/1.0.2 Python/3.10.15 (macOS-15.7-arm64-arm-64bit)'
    'Authorization': 'REDACTED'
No body was attached to the request

INFO:azure.core.pipeline.policies.http_logging_policy:Response status: 200
Response headers:
    'Content-Length': '106'
    'Content-Type': 'application/json; charset=utf-8'
    'retry-after': '1'
    'x-envoy-upstream-service-time': 'REDACTED'
    'apim-request-id': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'x-content-type-options': 'REDACTED'
    'x-ms-region': 'REDACTED'
    'Date': 'Wed, 24 Sep 2025 09:42:15 GMT'

INFO:azure.core.pipeline.policies.http_logging_policy:Request URL: 'https://DOMAIN.cognitiveservices.azure.com/documentintelligence/documentModels/prebuilt-read/analyzeResults/8fd23bd0-5b6c-4573-8f69-099a0aa89a24?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'x-ms-client-request-id': 'adfbd91c-992a-11f0-a7a4-46532a3ca5f1'
    'User-Agent': 'azsdk-python-ai-documentintelligence/1.0.2 Python/3.10.15 (macOS-15.7-arm64-arm-64bit)'
    'Authorization': 'REDACTED'
No body was attached to the request

INFO:azure.core.pipeline.policies.http_logging_policy:Response status: 200
Response headers:
    'Content-Length': '106'
    'Content-Type': 'application/json; charset=utf-8'
    'retry-after': '1'
    'x-envoy-upstream-service-time': 'REDACTED'
    'apim-request-id': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'x-content-type-options': 'REDACTED'
    'x-ms-region': 'REDACTED'
    'Date': 'Wed, 24 Sep 2025 09:42:16 GMT'

Screenshots

Additional context

aidangallagher4 avatar Sep 24 '25 09:09 aidangallagher4

@vkurpad @yungshinlintw

github-actions[bot] avatar Sep 24 '25 09:09 github-actions[bot]