taskwait
Wait for a task to complete. This is a very small package and does not really warrant this level of complexity in documentation. We're using this to help us bootstrap up some ideas around python doc generation.
Reference
Wait for a task to complete.
This module is inspired by our R "logwatch" package.
Result
dataclass
Result of waiting on a task.
Attributes
status (str):
The final status, returned by the status()
method
start (float):
The task start time, in seconds since the Epoch
end (float):
The task end time, in seconds since the Epoch
Source code in src/taskwait/__init__.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
Task
Bases: ABC
Base class for tasks.
Inherit from this class to create something suitable to pass into taskwait.
Attributes
status_waiting (set[str]): A set of statuses that are interpreted as "waiting" status_running (set[str]): A set of statuses that are interpreted as "running"
Source code in src/taskwait/__init__.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
has_log()
abstractmethod
Indicate if this task may produce logs (now or in future).
Source code in src/taskwait/__init__.py
43 44 45 46 |
|
log()
abstractmethod
Fetch logs for the task, if available.
Source code in src/taskwait/__init__.py
38 39 40 41 |
|
status()
abstractmethod
Query for the status of the task.
Source code in src/taskwait/__init__.py
33 34 35 36 |
|
taskwait(task, *, show_log=True, progress=True, poll=1, timeout=None)
Wait for a task to complete.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
Task
|
The task to wait on. |
required |
show_log
|
bool
|
Show logs, if available, while waiting? |
True
|
progress
|
bool
|
Show a progress bar while waiting? Only shown
while running if |
True
|
poll
|
float
|
Period to poll for new status/logs, in seconds. |
1
|
timeout
|
float | None
|
(float | None): Time, in seconds, to wait before
throwing a |
None
|
Source code in src/taskwait/__init__.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|