File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,13 +171,23 @@ def test_parse_file_filled_single_page_must_succeed(
171171 assert len (supplier_name .locations ) == 0
172172
173173
174+ def _job_is_final (job : Job ) -> bool :
175+ if job .status == "Failed" :
176+ return True
177+ if job .status != "Processed" :
178+ return False
179+ # Webhook deliveries happen asynchronously after processing:
180+ # wait until every webhook has reached a final status as well.
181+ return all (webhook .status in {"Completed" , "Failed" } for webhook in job .webhooks )
182+
183+
174184def _enqueue_and_poll_job (v2_client : Client , input_source , params ) -> Job :
175- """Enqueue a document and poll until the job reaches a final status."""
185+ """Enqueue a document and poll until the job and its webhooks reach a final status."""
176186 job = v2_client .enqueue (input_source , params ).job
177187 for _ in range (60 ):
178188 sleep (2 )
179189 job = v2_client .get_job (job .id ).job
180- if job . status in { "Processed" , "Failed" } :
190+ if _job_is_final ( job ) :
181191 break
182192 return job
183193
You can’t perform that action at this time.
0 commit comments