2626from uuid import UUID , uuid5 , NAMESPACE_URL , NAMESPACE_OID
2727from datetime import timezone
2828
29- from azure .durable_functions .models .utils .json_utils import parse_datetime_attrib_timespan
29+ from azure .durable_functions .models .utils .json_utils import parse_timespan_attrib
3030
3131from .RetryOptions import RetryOptions
3232from .FunctionContext import FunctionContext
@@ -51,18 +51,20 @@ class DurableOrchestrationContext:
5151 def __init__ (self ,
5252 history : List [Dict [Any , Any ]], instanceId : str , isReplaying : bool ,
5353 parentInstanceId : str , input : Any = None , upperSchemaVersion : int = 0 ,
54- maximumShortTimerDuration = None , longRunningTimerIntervalDuration = None ,
55- upperSchemaVersionNew = None , ** kwargs ):
54+ maximumShortTimerDuration : str = None , longRunningTimerIntervalDuration : str = None ,
55+ upperSchemaVersionNew : int = None , ** kwargs ):
5656 self ._histories : List [HistoryEvent ] = [HistoryEvent (** he ) for he in history ]
5757 self ._instance_id : str = instanceId
5858 self ._is_replaying : bool = isReplaying
5959 self ._parent_instance_id : str = parentInstanceId
6060 self ._maximum_short_timer_duration : datetime .timedelta
6161 if maximumShortTimerDuration is not None :
62- self ._maximum_short_timer_duration = parse_datetime_attrib_timespan (maximumShortTimerDuration )
63- self ._long_running_timer_interval_duration : datetime .timedelta
62+ max_short_duration = parse_timespan_attrib (maximumShortTimerDuration )
63+ self ._maximum_short_timer_duration = max_short_duration
64+ self ._long_timer_interval_duration : datetime .timedelta
6465 if longRunningTimerIntervalDuration is not None :
65- self ._long_running_timer_interval_duration = parse_datetime_attrib_timespan (longRunningTimerIntervalDuration )
66+ long_interval_duration = parse_timespan_attrib (longRunningTimerIntervalDuration )
67+ self ._long_timer_interval_duration = long_interval_duration
6668 self ._custom_status : Any = None
6769 self ._new_uuid_counter : int = 0
6870 self ._sub_orchestrator_counter : int = 0
@@ -485,7 +487,7 @@ def parent_instance_id(self) -> str:
485487
486488 @property
487489 def maximum_short_timer_duration (self ) -> datetime .timedelta :
488- """Get the maximum duration for a short timer
490+ """Get the maximum duration for a short timer.
489491
490492 The maximum length of a "short timer" is defined by the storage backend.
491493 Some storage backends have a maximum future date for scheduled tasks, and
@@ -500,7 +502,7 @@ def maximum_short_timer_duration(self) -> datetime.timedelta:
500502 return self ._maximum_short_timer_duration
501503
502504 @property
503- def long_running_timer_interval_duration (self ) -> datetime .timedelta :
505+ def long_timer_interval_duration (self ) -> datetime .timedelta :
504506 """Get the interval for long timers.
505507
506508 When a timer is scheduled for a duration longer than the maximum short timer
@@ -512,7 +514,7 @@ def long_running_timer_interval_duration(self) -> datetime.timedelta:
512514 str
513515 Duration for intervals of a long-running timer
514516 """
515- return self ._long_running_timer_interval_duration
517+ return self ._long_timer_interval_duration
516518
517519 @property
518520 def current_utc_datetime (self ) -> datetime .datetime :
@@ -624,18 +626,21 @@ def create_timer(self, fire_at: datetime.datetime) -> TaskBase:
624626 A Durable Timer Task that schedules the timer to wake up the activity
625627 """
626628 if self ._replay_schema .value >= ReplaySchema .V3 .value :
627- if not self .maximum_short_timer_duration or not self .long_running_timer_interval_duration :
629+ if not self .maximum_short_timer_duration or not self .long_timer_interval_duration :
628630 raise Exception (
629- "A framework-internal error was detected: replay schema version >= V3 is being used, " +
630- "but one or more of the properties `maximumShortTimerDuration` and `longRunningTimerIntervalDuration` are not defined. " +
631+ "A framework-internal error was detected: " +
632+ "replay schema version >= V3 is being used, " +
633+ "but one or more of the properties `maximumShortTimerDuration`" +
634+ "and `longRunningTimerIntervalDuration` are not defined. " +
631635 "This is likely an issue with the Durable Functions Extension. " +
632- "Please report this bug here: https://github.com/Azure/azure-functions-durable-js/issues\n " +
636+ "Please report this bug here: " +
637+ "https://github.com/Azure/azure-functions-durable-python/issues\n " +
633638 f"maximumShortTimerDuration: { self .maximum_short_timer_duration } \n " +
634- f"longRunningTimerIntervalDuration: { self .long_running_timer_interval_duration } "
639+ f"longRunningTimerIntervalDuration: { self .long_timer_interval_duration } "
635640 )
636641 if fire_at > self .current_utc_datetime + self .maximum_short_timer_duration :
637642 action = CreateTimerAction (fire_at )
638- return LongTimerTask (None , action , self , None , self . maximum_short_timer_duration , self . long_running_timer_interval_duration )
643+ return LongTimerTask (None , action , self )
639644
640645 action = CreateTimerAction (fire_at )
641646 task = self ._generate_task (action , task_constructor = TimerTask )
@@ -713,7 +718,8 @@ def _add_to_actions(self, action_repr: Union[List[Action], Action]):
713718
714719 if self ._replay_schema is ReplaySchema .V1 and isinstance (action_repr , list ):
715720 self ._action_payload_v1 .append (action_repr )
716- elif self ._replay_schema .value >= ReplaySchema .V2 .value and isinstance (action_repr , Action ):
721+ elif (self ._replay_schema .value >= ReplaySchema .V2 .value
722+ and isinstance (action_repr , Action )):
717723 self ._action_payload_v2 .append (action_repr )
718724 else :
719725 raise Exception (f"DF-internal exception: ActionRepr of signature { type (action_repr )} "
0 commit comments