Skip to content

Commit a5e5f25

Browse files
committed
Use custom exception
1 parent 2f4bbd9 commit a5e5f25

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/vws/exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,9 @@ def response(self) -> Response:
201201
The response returned by Vuforia which included this error.
202202
"""
203203
return self._response
204+
205+
206+
class TargetProcessingTimeout(Exception):
207+
"""
208+
Exception raised when waiting for a target to be processed times out.
209+
"""

src/vws/vws.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
MetadataTooLarge,
2323
ProjectInactive,
2424
TargetNameExist,
25+
TargetProcessingTimeout,
2526
TargetStatusProcessing,
2627
UnknownTarget,
2728
)
@@ -337,7 +338,10 @@ def wait_for_target_processed(
337338
target in the database.
338339
"""
339340

340-
@timeout(seconds=timeout_seconds)
341+
@timeout(
342+
seconds=timeout_seconds,
343+
timeout_exception=TargetProcessingTimeout,
344+
)
341345
def decorated() -> None:
342346
self._wait_for_target_processed(
343347
target_id=target_id,

tests/test_vws.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
from typing import Optional
77

88
import pytest
9-
import timeout_decorator
109
from mock_vws import MockVWS
1110
from mock_vws.database import VuforiaDatabase
1211

1312
from vws import VWS
14-
from vws.exceptions import UnknownTarget
13+
from vws.exceptions import TargetProcessingTimeout, UnknownTarget
1514

1615

1716
class TestAddTarget:
@@ -388,7 +387,7 @@ def test_custom_timeout(
388387

389388
report = client.get_target_summary_report(target_id=target_id)
390389
assert report['status'] == 'processing'
391-
with pytest.raises(timeout_decorator.TimeoutError):
390+
with pytest.raises(TargetProcessingTimeout):
392391
client.wait_for_target_processed(
393392
target_id=target_id,
394393
timeout_seconds=0.1,

0 commit comments

Comments
 (0)