diff --git a/labelbox/schema/task.py b/labelbox/schema/task.py index 717f12ff5..8ba91470c 100644 --- a/labelbox/schema/task.py +++ b/labelbox/schema/task.py @@ -58,14 +58,19 @@ def refresh(self) -> None: for field in self.fields(): setattr(self, field.name, getattr(tasks[0], field.name)) - def wait_till_done(self, timeout_seconds: int = 300) -> None: + def wait_till_done(self, + timeout_seconds: float = 300.0, + check_frequency: float = 2.0) -> None: """ Waits until the task is completed. Periodically queries the server - to update the task attributes. + to update the task attributes. - Args: - timeout_seconds (float): Maximum time this method can block, in seconds. Defaults to five minutes. - """ - check_frequency = 2 # frequency of checking, in seconds + Args: + timeout_seconds (float): Maximum time this method can block, in seconds. Defaults to five minutes. + check_frequency (float): Frequency of queries to server to update the task attributes, in seconds. Defaults to two seconds. Minimal value is two seconds. + """ + if check_frequency < 2.0: + raise ValueError( + "Expected check frequency to be two seconds or more") while timeout_seconds > 0: if self.status != "IN_PROGRESS": # self.errors fetches the error content.