|
6 | 6 | import io |
7 | 7 | import json |
8 | 8 | from datetime import date |
9 | | -from time import sleep |
10 | 9 | from typing import Dict, List, Optional, Union |
11 | 10 | from urllib.parse import urljoin |
12 | 11 |
|
|
15 | 14 | from vws_auth_tools import authorization_header, rfc_1123_date |
16 | 15 |
|
17 | 16 | from vws._result_codes import raise_for_result_code |
| 17 | +from vws._wait_for_target_processed import foobar |
18 | 18 | from vws.reports import ( |
19 | 19 | DatabaseSummaryReport, |
20 | 20 | TargetRecord, |
@@ -253,38 +253,6 @@ def get_target_record(self, target_id: str) -> TargetRecord: |
253 | 253 | ) |
254 | 254 | return target_record |
255 | 255 |
|
256 | | - def _wait_for_target_processed( |
257 | | - self, |
258 | | - target_id: str, |
259 | | - seconds_between_requests: float, |
260 | | - ) -> None: |
261 | | - """ |
262 | | - Wait indefinitely for a target to get past the processing stage. |
263 | | -
|
264 | | - Args: |
265 | | - target_id: The ID of the target to wait for. |
266 | | - seconds_between_requests: The number of seconds to wait between |
267 | | - requests made while polling the target status. |
268 | | -
|
269 | | - Raises: |
270 | | - ~vws.exceptions.AuthenticationFailure: The secret key is not |
271 | | - correct. |
272 | | - ~vws.exceptions.Fail: There was an error with the request. For |
273 | | - example, the given access key does not match a known database. |
274 | | - TimeoutError: The target remained in the processing stage for more |
275 | | - than five minutes. |
276 | | - ~vws.exceptions.UnknownTarget: The given target ID does not match a |
277 | | - target in the database. |
278 | | - ~vws.exceptions.RequestTimeTooSkewed: There is an error with the |
279 | | - time sent to Vuforia. |
280 | | - """ |
281 | | - while True: |
282 | | - report = self.get_target_summary_report(target_id=target_id) |
283 | | - if report.status != TargetStatuses.PROCESSING: |
284 | | - return |
285 | | - |
286 | | - sleep(seconds_between_requests) |
287 | | - |
288 | 256 | def wait_for_target_processed( |
289 | 257 | self, |
290 | 258 | target_id: str, |
@@ -318,8 +286,12 @@ def wait_for_target_processed( |
318 | 286 | ~vws.exceptions.RequestTimeTooSkewed: There is an error with the |
319 | 287 | time sent to Vuforia. |
320 | 288 | """ |
321 | | - from _wait_for_target_processed import foobar |
322 | | - foobar(vws_client=self) |
| 289 | + foobar( |
| 290 | + vws_client=self, |
| 291 | + target_id=target_id, |
| 292 | + timeout_seconds=timeout_seconds, |
| 293 | + seconds_between_requests=seconds_between_requests, |
| 294 | + ) |
323 | 295 |
|
324 | 296 | def list_targets(self) -> List[str]: |
325 | 297 | """ |
|
0 commit comments