Skip to content

Commit 2ba92ab

Browse files
committed
Implement
1 parent 65c2ad0 commit 2ba92ab

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
@@ -1023,6 +1023,9 @@ def workflow_get_update_validator(self, name: Optional[str]) -> Optional[Callabl
10231023
def workflow_info(self) -> temporalio.workflow.Info:
10241024
return self._outbound.info()
10251025

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

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

@@ -818,6 +821,15 @@ def info() -> Info:
818821
return _Runtime.current().workflow_info()
819822

820823

824+
def instance() -> Any:
825+
"""Current workflow's instance.
826+
827+
Returns:
828+
The currently running workflow instance.
829+
"""
830+
return _Runtime.current().workflow_instance()
831+
832+
821833
def memo() -> Mapping[str, Any]:
822834
"""Current workflow's memo values, converted without type hints.
823835

0 commit comments

Comments
 (0)