Skip to content

Commit fbea8c9

Browse files
authored
modified wait till done method to include check frequency as a argument (#1340)
1 parent 46c5f08 commit fbea8c9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

labelbox/schema/task.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,19 @@ def refresh(self) -> None:
5858
for field in self.fields():
5959
setattr(self, field.name, getattr(tasks[0], field.name))
6060

61-
def wait_till_done(self, timeout_seconds: int = 300) -> None:
61+
def wait_till_done(self,
62+
timeout_seconds: float = 300.0,
63+
check_frequency: float = 2.0) -> None:
6264
""" Waits until the task is completed. Periodically queries the server
63-
to update the task attributes.
65+
to update the task attributes.
6466
65-
Args:
66-
timeout_seconds (float): Maximum time this method can block, in seconds. Defaults to five minutes.
67-
"""
68-
check_frequency = 2 # frequency of checking, in seconds
67+
Args:
68+
timeout_seconds (float): Maximum time this method can block, in seconds. Defaults to five minutes.
69+
check_frequency (float): Frequency of queries to server to update the task attributes, in seconds. Defaults to two seconds. Minimal value is two seconds.
70+
"""
71+
if check_frequency < 2.0:
72+
raise ValueError(
73+
"Expected check frequency to be two seconds or more")
6974
while timeout_seconds > 0:
7075
if self.status != "IN_PROGRESS":
7176
# self.errors fetches the error content.

0 commit comments

Comments
 (0)