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

Method wait_for_processing

src/openai/resources/files.py:720–741  ·  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

718 )
719
720 async def wait_for_processing(
721 self,
722 id: str,
723 *,
724 poll_interval: float = 5.0,
725 max_wait_seconds: float = 30 * 60,
726 ) -> FileObject:
727 """Waits for the given file to be processed, default timeout is 30 mins."""
728 TERMINAL_STATES = {"processed", "error", "deleted"}
729
730 start = time.time()
731 file = await self.retrieve(id)
732 while file.status not in TERMINAL_STATES:
733 await self._sleep(poll_interval)
734
735 file = await self.retrieve(id)
736 if time.time() - start > max_wait_seconds:
737 raise RuntimeError(
738 f"Giving up on waiting for file {id} to finish processing after {max_wait_seconds} seconds."
739 )
740
741 return file
742
743
744class FilesWithRawResponse:

Callers

nothing calls this directly

Calls 2

retrieveMethod · 0.95
_sleepMethod · 0.45

Tested by

no test coverage detected