MCPcopy
hub / github.com/openai/openai-python / wait_for_processing

Method wait_for_processing

src/openai/resources/files.py:366–387  ·  src/openai/resources/files.py::Files.wait_for_processing

Waits for the given file to be processed, default timeout is 30 mins.

(
        self,
        id: str,
        *,
        poll_interval: float = 5.0,
        max_wait_seconds: float = 30 * 60,
    )

Source from the content-addressed store, hash-verified

364 )
365
366 def wait_for_processing(
367 self,
368 id: str,
369 *,
370 poll_interval: float = 5.0,
371 max_wait_seconds: float = 30 * 60,
372 ) -> FileObject:
373 class="st">""class="st">"Waits for the given file to be processed, default timeout is 30 mins."class="st">""
374 TERMINAL_STATES = {class="st">"processed", class="st">"error", class="st">"deleted"}
375
376 start = time.time()
377 file = self.retrieve(id)
378 while file.status not in TERMINAL_STATES:
379 self._sleep(poll_interval)
380
381 file = self.retrieve(id)
382 if time.time() - start > max_wait_seconds:
383 raise RuntimeError(
384 fclass="st">"Giving up on waiting for file {id} to finish processing after {max_wait_seconds} seconds."
385 )
386
387 return file
388
389
390class AsyncFiles(AsyncAPIResource):

Callers

nothing calls this directly

Calls 2

retrieveMethod · 0.95
_sleepMethod · 0.45

Tested by

no test coverage detected