@@ -331,7 +331,7 @@ def __init__(self, det: WorkflowInstanceDetails) -> None:
331331
332332 # The current details (as opposed to static details on workflow start), returned in the
333333 # metadata query
334- self ._current_details : str = ""
334+ self ._current_details = ""
335335
336336 def get_thread_id (self ) -> Optional [int ]:
337337 return self ._current_thread_id
@@ -1449,9 +1449,13 @@ async def workflow_sleep(
14491449 if summary
14501450 else None
14511451 )
1452+ fut = self .create_future ()
14521453 self ._timer_impl (
1453- duration , lambda _ : None , options = _TimerOptions (user_metadata = user_metadata )
1454+ duration ,
1455+ _TimerOptions (user_metadata = user_metadata ),
1456+ lambda : fut .set_result (None ),
14541457 )
1458+ await fut
14551459
14561460 async def workflow_wait_condition (
14571461 self ,
@@ -1476,9 +1480,9 @@ async def workflow_wait_condition(
14761480 def workflow_get_current_details (self ) -> str :
14771481 return self ._current_details
14781482
1479- def workflow_set_current_details (self , description ):
1483+ def workflow_set_current_details (self , details : str ):
14801484 self ._assert_not_read_only ("set current details" )
1481- self ._current_details = description
1485+ self ._current_details = details
14821486
14831487 #### Calls from outbound impl ####
14841488 # These are in alphabetical order and all start with "_outbound_".
@@ -2014,24 +2018,24 @@ def _enhanced_stack_trace(self) -> temporalio.api.sdk.v1.EnhancedStackTrace:
20142018 def _temporal_workflow_metadata (self ) -> temporalio .api .sdk .v1 .WorkflowMetadata :
20152019 query_definitions = [
20162020 temporalio .api .sdk .v1 .WorkflowInteractionDefinition (
2017- name = qd .name if qd . name is not None else "" ,
2018- description = qd .description if qd . description is not None else "" ,
2021+ name = qd .name or "" ,
2022+ description = qd .description or "" ,
20192023 )
20202024 for qd in self ._queries .values ()
20212025 ]
20222026 query_definitions .sort (key = lambda qd : qd .name )
20232027 signal_definitions = [
20242028 temporalio .api .sdk .v1 .WorkflowInteractionDefinition (
2025- name = sd .name if sd . name is not None else "" ,
2026- description = sd .description if sd . description is not None else "" ,
2029+ name = sd .name or "" ,
2030+ description = sd .description or "" ,
20272031 )
20282032 for sd in self ._signals .values ()
20292033 ]
20302034 signal_definitions .sort (key = lambda sd : sd .name )
20312035 update_definitions = [
20322036 temporalio .api .sdk .v1 .WorkflowInteractionDefinition (
2033- name = ud .name if ud . name is not None else "" ,
2034- description = ud .description if ud . description is not None else "" ,
2037+ name = ud .name or "" ,
2038+ description = ud .description or "" ,
20352039 )
20362040 for ud in self ._updates .values ()
20372041 ]
@@ -2050,10 +2054,10 @@ def _temporal_workflow_metadata(self) -> temporalio.api.sdk.v1.WorkflowMetadata:
20502054 def _timer_impl (
20512055 self ,
20522056 delay : float ,
2057+ options : _TimerOptions ,
20532058 callback : Callable [..., Any ],
20542059 * args : Any ,
20552060 context : Optional [contextvars .Context ] = None ,
2056- options : Optional [_TimerOptions ] = None ,
20572061 ):
20582062 self ._assert_not_read_only ("schedule timer" )
20592063 # Delay must be positive
@@ -2062,12 +2066,6 @@ def _timer_impl(
20622066
20632067 # Create, schedule, and return
20642068 seq = self ._next_seq ("timer" )
2065- # If options aren't explicitly passed, attempt to fetch them from the class field,
2066- # erasing them afterward. Support callers who cannot call this directly because they
2067- # rely on asyncio functions.
2068- if options is None :
2069- options = self ._next_timer_options
2070- self ._next_timer_options = None
20712069 handle = _TimerHandle (
20722070 seq , self .time () + delay , options , callback , args , self , context
20732071 )
@@ -2079,7 +2077,6 @@ def _timer_impl(
20792077 # These are in the order defined in CPython's impl of the base class. Many
20802078 # functions are intentionally not implemented/supported.
20812079
2082- # TODO/Review: This doesn't appear to implement any base class fn and isn't called anywhere?
20832080 def _timer_handle_cancelled (self , handle : asyncio .TimerHandle ) -> None :
20842081 if not isinstance (handle , _TimerHandle ):
20852082 raise TypeError ("Expected Temporal timer handle" )
@@ -2107,7 +2104,12 @@ def call_later(
21072104 * args : Any ,
21082105 context : Optional [contextvars .Context ] = None ,
21092106 ) -> asyncio .TimerHandle :
2110- return self ._timer_impl (delay , callback , * args , context = context )
2107+ # Fetch options from the class field, erasing them afterward.
2108+ options = (
2109+ self ._next_timer_options if self ._next_timer_options else _TimerOptions ()
2110+ )
2111+ self ._next_timer_options = None
2112+ return self ._timer_impl (delay , options , callback , * args , context = context )
21112113
21122114 def call_at (
21132115 self ,
0 commit comments