Skip to content

Commit c50b6d5

Browse files
committed
Allow custom wait between requests on wait for target processed
1 parent 64c4b1c commit c50b6d5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/vws/vws.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,22 @@ def _wait_for_target_processed(
307307
sleep(seconds_between_requests)
308308

309309
@timeout_decorator.timeout(seconds=60 * 5)
310-
def wait_for_target_processed(self, target_id: str) -> None:
310+
def wait_for_target_processed(
311+
self,
312+
target_id: str,
313+
seconds_between_requests: float = 0.2,
314+
) -> None:
311315
"""
312316
Wait up to five minutes (arbitrary) for a target to get past the
313317
processing stage.
314318
315319
Args:
316320
target_id: The ID of the target to wait for.
321+
seconds_between_requests: The number of seconds to wait between
322+
requests made while polling the target status.
323+
We wait 0.2 seconds by default, rather than less, than that to
324+
decrease the number of calls made to the API, to decrease the
325+
likelihood of hitting the request quota.
317326
318327
Raises:
319328
~vws.exceptions.AuthenticationFailure: The secret key is not
@@ -325,10 +334,6 @@ def wait_for_target_processed(self, target_id: str) -> None:
325334
~vws.exceptions.UnknownTarget: The given target ID does not match a
326335
target in the database.
327336
"""
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
332337
self._wait_for_target_processed(
333338
target_id=target_id,
334339
seconds_between_requests=seconds_between_requests,

0 commit comments

Comments
 (0)