Skip to content

Commit 8fffd37

Browse files
committed
Progress towards moving helper to external
1 parent 11b890b commit 8fffd37

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
This is tooling for waiting for a target to be processed.
3+
4+
It lives here rather than in ``vws.py`` to support Windows.
5+
"""
6+
7+
from typing import Optional
8+
9+
from wrapt_timeout_decorator import timeout
10+
11+
from vws import VWS
12+
from vws.exceptions import TargetProcessingTimeout
13+
14+
15+
def foobar(
16+
vws_client: VWS,
17+
timeout_seconds: Optional[float],
18+
seconds_between_requests: float,
19+
target_id: str,
20+
):
21+
22+
@timeout(
23+
dec_timeout=timeout_seconds,
24+
timeout_exception=TargetProcessingTimeout,
25+
use_signals=False,
26+
)
27+
def decorated() -> None:
28+
vws_client._wait_for_target_processed(
29+
target_id=target_id,
30+
seconds_between_requests=seconds_between_requests,
31+
)
32+
33+
decorated()

src/vws/vws.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
import requests
1414
from requests import Response
15-
from wrapt_timeout_decorator import timeout
1615
from vws_auth_tools import authorization_header, rfc_1123_date
1716

1817
from vws._result_codes import raise_for_result_code
19-
from vws.exceptions import TargetProcessingTimeout
2018
from vws.reports import (
2119
DatabaseSummaryReport,
2220
TargetRecord,
@@ -320,19 +318,8 @@ def wait_for_target_processed(
320318
~vws.exceptions.RequestTimeTooSkewed: There is an error with the
321319
time sent to Vuforia.
322320
"""
323-
324-
@timeout(
325-
dec_timeout=timeout_seconds,
326-
timeout_exception=TargetProcessingTimeout,
327-
use_signals=False,
328-
)
329-
def decorated() -> None:
330-
self._wait_for_target_processed(
331-
target_id=target_id,
332-
seconds_between_requests=seconds_between_requests,
333-
)
334-
335-
decorated()
321+
from _wait_for_target_processed import foobar
322+
foobar(vws_client=self)
336323

337324
def list_targets(self) -> List[str]:
338325
"""

0 commit comments

Comments
 (0)