Skip to content

Commit

Permalink
Implement
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Jan 18, 2025
1 parent ec5a6b8 commit 5d752a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions temporalio/worker/_workflow_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,9 @@ def workflow_get_update_validator(self, name: Optional[str]) -> Optional[Callabl
def workflow_info(self) -> temporalio.workflow.Info:
return self._outbound.info()

def workflow_instance(self) -> Any:
return self._object

def workflow_is_continue_as_new_suggested(self) -> bool:
return self._continue_as_new_suggested

Expand Down
12 changes: 12 additions & 0 deletions temporalio/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ def workflow_get_update_validator(
@abstractmethod
def workflow_info(self) -> Info: ...

@abstractmethod
def workflow_instance(self) -> Any: ...

@abstractmethod
def workflow_is_continue_as_new_suggested(self) -> bool: ...

Expand Down Expand Up @@ -821,6 +824,15 @@ def info() -> Info:
return _Runtime.current().workflow_info()


def instance() -> Any:
"""Current workflow's instance.
Returns:
The currently running workflow instance.
"""
return _Runtime.current().workflow_instance()


def memo() -> Mapping[str, Any]:
"""Current workflow's memo values, converted without type hints.
Expand Down

0 comments on commit 5d752a6

Please sign in to comment.