The state of one workflow run (Effect's WorkflowInstance
service): its execution id and workflow, a scope closed only when the
execution completes, and the flags the engine and the run set.
awaited_deferreds counts the durable waits of the run per deferred
name (a completion of one of them preempts the run);
completed_deferreds names those the run completed itself.
Attributes#
| Attribute | Type | Description |
|---|---|---|
execution_id | = execution_id | |
workflow | = workflow | |
scope | = scope | |
suspended | = False | |
interrupted | = False | |
abandoned | = False | |
cause | Cause[Never] | None = None | |
failed | = False | |
awaited_deferreds | = awaited_deferreds | |
completed_deferreds | = completed_deferreds | |
activity_state | = activity_state |
Functions#
__init__#
__init__(workflow, execution_id, *, scope, awaited_deferreds, completed_deferreds, activity_state) -> None| Parameter | Type | Description |
|---|---|---|
workflow | Workflow[Any, Any, Any] | |
execution_id | str | |
scope | CloseableScope | |
awaited_deferreds | dict[str, int] | |
completed_deferreds | set[str] | |
activity_state | ActivityState |
def __init__(
self,
workflow: Workflow[Any, Any, Any],
execution_id: str,
*,
scope: CloseableScope,
awaited_deferreds: dict[str, int],
completed_deferreds: set[str],
activity_state: ActivityState,
) -> None:
self.execution_id = execution_id
self.workflow = workflow
self.scope = scope
self.suspended = False
self.interrupted = False
self.abandoned = False
self.cause: Cause[Never] | None = None
self.failed = False
self.awaited_deferreds = awaited_deferreds
self.completed_deferreds = completed_deferreds
self.activity_state = activity_stateinitial#
initial(workflow, execution_id, *, scope=None, awaited_deferreds=None) -> WorkflowInstanceServiceA fresh run: not suspended, interrupted, abandoned or failed.
awaited_deferreds shares the waits of the run an activity
instance belongs to.
| Parameter | Type | Description |
|---|---|---|
workflow | Workflow[Any, Any, Any] | |
execution_id | str | |
scope | CloseableScope | None = None | |
awaited_deferreds | dict[str, int] | None = None |
Returns WorkflowInstanceService
@staticmethod
def initial(
workflow: Workflow[Any, Any, Any],
execution_id: str,
*,
scope: CloseableScope | None = None,
awaited_deferreds: dict[str, int] | None = None,
) -> WorkflowInstanceService:
"""A fresh run: not suspended, interrupted, abandoned or failed.
``awaited_deferreds`` shares the waits of the run an activity
instance belongs to."""
return WorkflowInstanceService(
workflow,
execution_id,
scope=CloseableScope() if scope is None else scope,
awaited_deferreds={} if awaited_deferreds is None else awaited_deferreds,
completed_deferreds=set(),
activity_state=ActivityState(),
)copy#
copy() -> WorkflowInstanceServiceA copy sharing the scope and the deferred bookkeeping, with its
own activity state and not suspended (Effect's { ...instance, suspended: false, activityState: ... }).
Returns WorkflowInstanceService
def copy(self) -> WorkflowInstanceService:
"""A copy sharing the scope and the deferred bookkeeping, with its
own activity state and not suspended (Effect's ``{ ...instance,
suspended: false, activityState: ... }``)."""
copied = WorkflowInstanceService(
self.workflow,
self.execution_id,
scope=self.scope,
awaited_deferreds=self.awaited_deferreds,
completed_deferreds=self.completed_deferreds,
activity_state=ActivityState(),
)
copied.interrupted = self.interrupted
copied.abandoned = self.abandoned
copied.cause = self.cause
copied.failed = self.failed
return copied