Skip to content

Commit ef8343c

Browse files
committed
Progress
1 parent c229df8 commit ef8343c

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/vws/vws.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,18 @@ def get_target_record(self, target_id: str) -> Dict[str, Union[str, int]]:
276276

277277
return dict(response.json()['target_record'])
278278

279-
def _wait_for_target_processed(self, target_id: str) -> None:
279+
def _wait_for_target_processed(
280+
self,
281+
target_id: str,
282+
seconds_between_requests: float,
283+
) -> None:
280284
"""
281285
Wait indefinitely for a target to get past the processing stage.
282286
283287
Args:
284288
target_id: The ID of the target to wait for.
289+
seconds_between_requests: The number of seconds to wait between
290+
requests made while polling the target status.
285291
286292
Raises:
287293
~vws.exceptions.AuthenticationFailure: The secret key is not
@@ -298,10 +304,7 @@ def _wait_for_target_processed(self, target_id: str) -> None:
298304
if report['status'] != 'processing':
299305
return
300306

301-
# We wait 0.2 seconds rather than less than that to decrease the
302-
# number of calls made to the API, to decrease the likelihood of
303-
# hitting the request quota.
304-
sleep(0.2)
307+
sleep(seconds_between_requests)
305308

306309
@timeout_decorator.timeout(seconds=60 * 5)
307310
def wait_for_target_processed(self, target_id: str) -> None:
@@ -322,6 +325,14 @@ def wait_for_target_processed(self, target_id: str) -> None:
322325
~vws.exceptions.UnknownTarget: The given target ID does not match a
323326
target in the database.
324327
"""
328+
# We wait 0.2 seconds rather than less than that to decrease the
329+
# number of calls made to the API, to decrease the likelihood of
330+
# hitting the request quota.
331+
seconds_between_requests = 0.2
332+
_wait_for_target_processed(
333+
target_id=target_id,
334+
seconds_between_requests=seconds_between_requests,
335+
)
325336

326337
def list_targets(self) -> List[str]:
327338
"""

0 commit comments

Comments
 (0)