Skip to content

Commit 5d752a6

Browse files
committed
Implement
1 parent ec5a6b8 commit 5d752a6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

temporalio/worker/_workflow_instance.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@ def workflow_get_update_validator(self, name: Optional[str]) -> Optional[Callabl
10221022
def workflow_info(self) -> temporalio.workflow.Info:
10231023
return self._outbound.info()
10241024

1025+
def workflow_instance(self) -> Any:
1026+
return self._object
1027+
10251028
def workflow_is_continue_as_new_suggested(self) -> bool:
10261029
return self._continue_as_new_suggested
10271030

temporalio/workflow.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ def workflow_get_update_validator(
625625
@abstractmethod
626626
def workflow_info(self) -> Info: ...
627627

628+
@abstractmethod
629+
def workflow_instance(self) -> Any: ...
630+
628631
@abstractmethod
629632
def workflow_is_continue_as_new_suggested(self) -> bool: ...
630633

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

823826

827+
def instance() -> Any:
828+
"""Current workflow's instance.
829+
830+
Returns:
831+
The currently running workflow instance.
832+
"""
833+
return _Runtime.current().workflow_instance()
834+
835+
824836
def memo() -> Mapping[str, Any]:
825837
"""Current workflow's memo values, converted without type hints.
826838

0 commit comments

Comments
 (0)