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

Method poll

src/openai/resources/videos.py:171–208  ·  view source on GitHub ↗

Wait for the vector store file to finish processing. Note: this will return even if the file failed to process, you need to check file.last_error and file.status to handle these cases

(
        self,
        video_id: str,
        *,
        poll_interval_ms: int | Omit = omit,
    )

Source from the content-addressed store, hash-verified

169 )
170
171 def poll(
172 self,
173 video_id: str,
174 *,
175 poll_interval_ms: int | Omit = omit,
176 ) -> Video:
177 """Wait for the vector store file to finish processing.
178
179 Note: this will return even if the file failed to process, you need to check
180 file.last_error and file.status to handle these cases
181 """
182 headers: dict[str, str] = {"X-Stainless-Poll-Helper": "true"}
183 if is_given(poll_interval_ms):
184 headers["X-Stainless-Custom-Poll-Interval"] = str(poll_interval_ms)
185
186 while True:
187 response = self.with_raw_response.retrieve(
188 video_id,
189 extra_headers=headers,
190 )
191
192 video = response.parse()
193 if video.status == "in_progress" or video.status == "queued":
194 if not is_given(poll_interval_ms):
195 from_header = response.headers.get("openai-poll-after-ms")
196 if from_header is not None:
197 poll_interval_ms = int(from_header)
198 else:
199 poll_interval_ms = 1000
200
201 self._sleep(poll_interval_ms / 1000)
202 elif video.status == "completed" or video.status == "failed":
203 return video
204 else:
205 if TYPE_CHECKING: # type: ignore[unreachable]
206 assert_never(video.status)
207 else:
208 return video
209
210 def retrieve(
211 self,

Callers 1

create_and_pollMethod · 0.95

Calls 5

is_givenFunction · 0.85
retrieveMethod · 0.45
parseMethod · 0.45
getMethod · 0.45
_sleepMethod · 0.45

Tested by

no test coverage detected