An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
Hi Krishan,
This is how the async poller in azure-core behaves, not a service problem. The job is already done; the poller just hasn't asked the service yet.
Why done() is False and status() is InProgress
-
get_analyze_batch_result(token)rebuilds the poller from the continuation token without making any request. The token stores the initial202 Acceptedresponse frombegin_analyze_batch_documents, sostatus()returns the status saved at submission time,InProgress. - On the async
AsyncLROPoller,done()only returnsTrueafterwait()/result()has finished. Unlike the sync poller, it never polls in the background. -
await poller.result()sends the first GET, seessucceeded, and returns straight away. That is why you get the counts even thoughdone()said False a moment earlier.
Check the status without blocking
Ask the poller to send a single status request, then decide:
poller = await client.get_analyze_batch_result(continuation_token)
await poller.polling_method().update_status() # one GET, no waiting
print(poller.status()) # e.g. "running", "succeeded", "failed"
if poller.polling_method().finished(): # succeeded, failed or canceled
result = await poller.result() # returns immediately, no extra polling
print(result.succeeded_count, result.failed_count, result.skipped_count)
else:
# not finished: put the message back on the queue and check again later
...
finished() is also True for failed / canceled; await poller.result() then raises HttpResponseError with the error details, so wrap it in try/except if your queue worker should not crash.
I checked this against azure-ai-documentintelligence 1.0.2 and azure-core 1.39.0 with a mocked service: before the call, done() is False and status() is InProgress with no request sent; after update_status(), status() is succeeded and finished() is True after exactly one GET; and when the job is still running, finished() stays False.
Alternatives, if you prefer:
- Use the sync client in the worker: its
LROPollerpolls in a background thread, sodone()updates on its own. - Call the REST endpoint directly:
GET {endpoint}/documentintelligence/documentModels/{modelId}/analyzeBatchResults/{resultId}?api-version=2024-11-30returnsstatusandpercentCompleted.
I've also added this explanation to the SDK issue you opened (Azure/azure-sdk-for-python#47972).
If this answers your question, please accept the answer so others can find it.