|
3 | 3 |
|
4 | 4 |
|
5 | 5 | class TaskSet:
|
6 |
| - def __init__(self, isCompleted, actions, result, isFaulted=False, e=None): |
7 |
| - self.isCompleted: bool = isCompleted |
8 |
| - self.actions: List[IAction] = actions |
9 |
| - self.result = result |
10 |
| - self.isFaulted: bool = isFaulted |
11 |
| - self.exception = e |
| 6 | + """Represents a list of some pending action. |
| 7 | +
|
| 8 | + Similar to a native JavaScript promise in |
| 9 | + that it acts as a placeholder for outstanding asynchronous work, but has |
| 10 | + a synchronous implementation and is specific to Durable Functions. |
| 11 | +
|
| 12 | + Tasks are only returned to an orchestration function when a |
| 13 | + [[DurableOrchestrationContext]] operation is not called with `yield`. They |
| 14 | + are useful for parallelization and timeout operations in conjunction with |
| 15 | + Task.all and Task.any. |
| 16 | + """ |
| 17 | + |
| 18 | + def __init__(self, is_completed, actions, result, is_faulted=False, exception=None): |
| 19 | + self._is_completed: bool = is_completed |
| 20 | + self._actions: List[IAction] = actions |
| 21 | + self._result = result |
| 22 | + self._is_faulted: bool = is_faulted |
| 23 | + self._exception = exception |
| 24 | + |
| 25 | + @property |
| 26 | + def is_completed(self) -> bool: |
| 27 | + """Get indicator whether the task has completed. |
| 28 | +
|
| 29 | + Note that completion is not equivalent to success. |
| 30 | + """ |
| 31 | + return self._is_completed |
| 32 | + |
| 33 | + @property |
| 34 | + def is_faulted(self) -> bool: |
| 35 | + """Get indicator whether the task faulted in some way due to error.""" |
| 36 | + return self._is_faulted |
| 37 | + |
| 38 | + @property |
| 39 | + def actions(self) -> IAction: |
| 40 | + """Get the scheduled action represented by the task. |
| 41 | +
|
| 42 | + _Internal use only._ |
| 43 | + """ |
| 44 | + return self._actions |
| 45 | + |
| 46 | + @property |
| 47 | + def result(self) -> object: |
| 48 | + """Get the result of the task, if completed. Otherwise `None`.""" |
| 49 | + return self._result |
| 50 | + |
| 51 | + @property |
| 52 | + def exception(self): |
| 53 | + """Get the error thrown when attempting to perform the task's action. |
| 54 | +
|
| 55 | + If the Task has not yet completed or has completed successfully, `None` |
| 56 | + """ |
| 57 | + return self._exception |
0 commit comments