@@ -414,7 +414,7 @@ def activate(
414414 # We want some errors during activation, like those that can happen
415415 # during payload conversion, to be able to fail the workflow not the
416416 # task
417- if self .is_workflow_failure_exception (err ):
417+ if self .workflow_is_failure_exception (err ):
418418 try :
419419 self ._set_workflow_failure (err )
420420 except Exception as inner_err :
@@ -629,7 +629,7 @@ async def run_update() -> None:
629629 # Validation failures are always update failures. We reuse
630630 # workflow failure logic to decide task failure vs update
631631 # failure after validation.
632- if not past_validation or self .is_workflow_failure_exception (err ):
632+ if not past_validation or self .workflow_is_failure_exception (err ):
633633 if command is None :
634634 command = self ._add_command ()
635635 command .update_response .protocol_instance_id = (
@@ -1686,6 +1686,23 @@ def workflow_set_current_details(self, details: str):
16861686 self ._assert_not_read_only ("set current details" )
16871687 self ._current_details = details
16881688
1689+ def workflow_is_failure_exception (self , err : BaseException ) -> bool :
1690+ # An exception is a failure instead of a task fail if it's already a
1691+ # failure error or if it is a timeout error or if it is an instance of
1692+ # any of the failure types in the worker or workflow-level setting
1693+ wf_failure_exception_types = self ._defn .failure_exception_types
1694+ if self ._dynamic_failure_exception_types is not None :
1695+ wf_failure_exception_types = self ._dynamic_failure_exception_types
1696+ return (
1697+ isinstance (err , temporalio .exceptions .FailureError )
1698+ or isinstance (err , asyncio .TimeoutError )
1699+ or any (isinstance (err , typ ) for typ in wf_failure_exception_types )
1700+ or any (
1701+ isinstance (err , typ )
1702+ for typ in self ._worker_level_failure_exception_types
1703+ )
1704+ )
1705+
16891706 #### Calls from outbound impl ####
16901707 # These are in alphabetical order and all start with "_outbound_".
16911708
@@ -1939,7 +1956,7 @@ def _convert_payloads(
19391956 # Don't wrap payload conversion errors that would fail the workflow
19401957 raise
19411958 except Exception as err :
1942- if self .is_workflow_failure_exception (err ):
1959+ if self .workflow_is_failure_exception (err ):
19431960 raise
19441961 raise RuntimeError ("Failed decoding arguments" ) from err
19451962
@@ -1982,23 +1999,6 @@ def _instantiate_workflow_object(self) -> Any:
19821999
19832000 return workflow_instance
19842001
1985- def is_workflow_failure_exception (self , err : BaseException ) -> bool :
1986- # An exception is a failure instead of a task fail if it's already a
1987- # failure error or if it is a timeout error or if it is an instance of
1988- # any of the failure types in the worker or workflow-level setting
1989- wf_failure_exception_types = self ._defn .failure_exception_types
1990- if self ._dynamic_failure_exception_types is not None :
1991- wf_failure_exception_types = self ._dynamic_failure_exception_types
1992- return (
1993- isinstance (err , temporalio .exceptions .FailureError )
1994- or isinstance (err , asyncio .TimeoutError )
1995- or any (isinstance (err , typ ) for typ in wf_failure_exception_types )
1996- or any (
1997- isinstance (err , typ )
1998- for typ in self ._worker_level_failure_exception_types
1999- )
2000- )
2001-
20022002 def _warn_if_unfinished_handlers (self ) -> None :
20032003 def warnable (handler_executions : Iterable [HandlerExecution ]):
20042004 return [
@@ -2192,7 +2192,7 @@ async def _run_top_level_workflow_function(self, coro: Awaitable[None]) -> None:
21922192 err
21932193 ):
21942194 self ._add_command ().cancel_workflow_execution .SetInParent ()
2195- elif self .is_workflow_failure_exception (err ):
2195+ elif self .workflow_is_failure_exception (err ):
21962196 # All other failure errors fail the workflow
21972197 self ._set_workflow_failure (err )
21982198 else :
0 commit comments