MCPcopy Index your code
hub / github.com/openai/openai-python / wait_for_processing

Method wait_for_processing

src/openai/resources/files.py:366–387  ·  view source on GitHub ↗

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 """Waits for the given file to be processed, default timeout is 30 mins."""
374 TERMINAL_STATES = {"processed", "error", "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 f"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