@@ -228,7 +228,7 @@ def call_sub_orchestrator(self, orchestrator: Union[Orchestrator[TInput, TOutput
228228 """
229229 pass
230230
231- # TOOD: Add a timeout parameter, which allows the task to be canceled if the event is
231+ # TOOD: Add a timeout parameter, which allows the task to be cancelled if the event is
232232 # not received within the specified timeout. This requires support for task cancellation.
233233 @abstractmethod
234234 def wait_for_external_event (self , name : str ) -> CancellableTask :
@@ -324,8 +324,8 @@ class OrchestrationStateError(Exception):
324324 pass
325325
326326
327- class TaskCanceledError (Exception ):
328- """Exception type for canceled orchestration tasks."""
327+ class TaskCancelledError (Exception ):
328+ """Exception type for cancelled orchestration tasks."""
329329
330330
331331class Task (ABC , Generic [T ]):
@@ -440,7 +440,7 @@ def fail(self, message: str, details: Union[Exception, pb.TaskFailureDetails]):
440440
441441
442442class CancellableTask (CompletableTask [T ]):
443- """A completable task that can be canceled before it finishes."""
443+ """A completable task that can be cancelled before it finishes."""
444444
445445 def __init__ (self ) -> None :
446446 super ().__init__ ()
@@ -449,12 +449,12 @@ def __init__(self) -> None:
449449
450450 @property
451451 def is_cancelled (self ) -> bool :
452- """Returns True if the task was canceled , False otherwise."""
452+ """Returns True if the task was cancelled , False otherwise."""
453453 return self ._is_cancelled
454454
455455 def get_result (self ) -> T :
456456 if self ._is_cancelled :
457- raise TaskCanceledError ('The task was canceled .' )
457+ raise TaskCancelledError ('The task was cancelled .' )
458458 return super ().get_result ()
459459
460460 def set_cancel_handler (self , cancel_handler : Callable [[], None ]) -> None :
@@ -524,27 +524,26 @@ class TimerTask(CancellableTask[None]):
524524 def set_retryable_parent (self , retryable_task : RetryableTask ):
525525 self ._retryable_parent = retryable_task
526526
527- def complete (self , * args , ** kwargs ) :
527+ def complete (self , _ : datetime ) -> None :
528528 super ().complete (None )
529529
530-
531530class LongTimerTask (TimerTask ):
532- def __init__ (self , final_fire_at : datetime , maximum_timer_duration : timedelta ):
531+ def __init__ (self , final_fire_at : datetime , maximum_timer_interval : timedelta ):
533532 super ().__init__ ()
534533 self ._final_fire_at = final_fire_at
535- self ._maximum_timer_duration = maximum_timer_duration
534+ self ._maximum_timer_interval = maximum_timer_interval
536535
537536 def start (self , current_utc_datetime : datetime ) -> datetime :
538537 return self ._get_next_fire_at (current_utc_datetime )
539538
540- def complete (self , current_utc_datetime : datetime ):
539+ def complete (self , current_utc_datetime : datetime ) -> Optional [ datetime ] :
541540 if current_utc_datetime < self ._final_fire_at :
542541 return self ._get_next_fire_at (current_utc_datetime )
543- super ().complete (None )
542+ return super ().complete (current_utc_datetime )
544543
545544 def _get_next_fire_at (self , current_utc_datetime : datetime ) -> datetime :
546- if current_utc_datetime + self ._maximum_timer_duration < self ._final_fire_at :
547- return current_utc_datetime + self ._maximum_timer_duration
545+ if current_utc_datetime + self ._maximum_timer_interval < self ._final_fire_at :
546+ return current_utc_datetime + self ._maximum_timer_interval
548547 return self ._final_fire_at
549548
550549
0 commit comments