FormRecognizer behavior when service starts throttling
- Package Name: azure-ai-formrecognizer
- Package Version: 3.2.0
- Operating System: Windows / Linux
- Python Version: 3.8 / 3.9
Describe the bug When service form recognizer starts to throttle it raises error I/O Operation on closed file.
To Reproduce Please check code snippet below. `
async def analyse_document_async(document: io.BytesIO):
endpoint, key = ...
# instantiate client
document_analysis_client = DocumentAnalysisClient(
endpoint=endpoint, credential=AzureKeyCredential(key)
)
# generate analysis_args
analysis_args = {"model_id": "prebuilt-invoice", "document": document}
# non blocking async call
async with document_analysis_client:
# Suppose to raise HttpError 429 when service starts to throttle (during scale-out)
# Instead raise I/O Operation on closed file...
poller = await document_analysis_client.begin_analyze_document(**analysis_args)
result = await poller.result()
return result
async def orchestrate_async_function(documents: List[io.BytesIO]):
tasks = [asyncio.create_task(analyse_document_async(doc)) for doc in documents]
# concurrent call
finished, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_EXCEPTION)
return finished
`
Expected behavior Should raise HttpError 429
Label prediction was below confidence level 0.6 for Model:ServiceLabels: 'Storage:0.12575616,Cognitive - Form Recognizer:0.12186136,Service Bus:0.104554616'
Thanks for the feedback, we’ll investigate asap.
Thanks for reaching out @dev-td! If possible, could you please share the error message you're getting?
~~@vkurpad could you loop someone in from the service team to take a look?~~ [not a service issue]
Hi @catalinaperalta , sure it's ValueError: I/O operation on closed file I can try to provide the error stack of that helps.
@catalinaperalta possibly related: https://github.com/Azure/azure-sdk-for-python/issues/20040
Ah I see, thanks for the info @dev-td and @kristapratico. Let me take a look
Hi @dev-td, I wanted to follow up and let you know that we're still looking into a fix for this issue. In the meantime, if possible, could you share the error stack please?
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!