bayesline.api.Task#
- class bayesline.api.Task#
-
Abstract base class representing a task that produces a result of type T.
A task has a unique ID and can be in various states (queued, running, completed, etc). The task’s progress can be monitored and its result retrieved once complete.
Methods
__init__
()Get the current progress status of the task.
Get the result of the completed task.
is_ready
()Check if the task has completed and the result is ready.
wait_ready
([timeout, check_interval])Wait for the task to be ready.
wait_result
([timeout, check_interval])Wait for the task to complete and return its result.
Attributes
Returns str The unique identifier for this task.
- abstract get_progress() TaskProgress #
Get the current progress status of the task.
Returns#
- TaskProgress
The current progress status, containing information about completion percentage and status message.
- abstract is_ready() bool #
Check if the task has completed and the result is ready.
Returns#
- bool
True if the task is complete and result can be retrieved, False otherwise.
- abstract get_result() T #
Get the result of the completed task.
Returns#
- T
The result of the task.
Raises#
- TaskError
If the task failed or is not yet complete.
- abstract wait_result(timeout: float = -1.0, check_interval: float = 0.5) T #
Wait for the task to complete and return its result.
Parameters#
- timeout: float, default=-1.0
Maximum time in seconds to wait for completion. A negative value means wait indefinitely.
- check_interval: float, default=0.5
Time in seconds between status checks.
Returns#
- T
The result of the task.
Raises#
- TaskError
If the task failed or timed out.
- abstract wait_ready(timeout: float = -1.0, check_interval: float = 1.0) None #
Wait for the task to be ready.
Parameters#
- timeout: float, default=-1.0
Maximum time in seconds to wait for completion. A negative value means wait indefinitely.
- check_interval: float, default=0.5
Time in seconds between status checks.
Raises#
- TaskError
If the task failed or timed out.