Skip to content

Commit 8c359a1

Browse files
committed
Naming consistency
1 parent d194b8b commit 8c359a1

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

azure/durable_functions/models/DurableOrchestrationContext.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def parent_instance_id(self) -> str:
492492
return self._parent_instance_id
493493

494494
@property
495-
def maximum_short_timer_duration(self) -> datetime.timedelta:
495+
def _maximum_short_timer_duration(self) -> datetime.timedelta:
496496
"""Get the maximum duration for a short timer.
497497
498498
The maximum length of a "short timer" is defined by the storage backend.
@@ -508,7 +508,7 @@ def maximum_short_timer_duration(self) -> datetime.timedelta:
508508
return self._maximum_short_timer_duration
509509

510510
@property
511-
def long_timer_interval_duration(self) -> datetime.timedelta:
511+
def _long_timer_interval_duration(self) -> datetime.timedelta:
512512
"""Get the interval for long timers.
513513
514514
When a timer is scheduled for a duration longer than the maximum short timer
@@ -632,7 +632,7 @@ def create_timer(self, fire_at: datetime.datetime) -> TaskBase:
632632
A Durable Timer Task that schedules the timer to wake up the activity
633633
"""
634634
if self._replay_schema.value >= ReplaySchema.V3.value:
635-
if not self.maximum_short_timer_duration or not self.long_timer_interval_duration:
635+
if not self._maximum_short_timer_duration or not self._long_timer_interval_duration:
636636
raise Exception(
637637
"A framework-internal error was detected: "
638638
"replay schema version >= V3 is being used, "
@@ -641,10 +641,10 @@ def create_timer(self, fire_at: datetime.datetime) -> TaskBase:
641641
"This is likely an issue with the Durable Functions Extension. "
642642
"Please report this bug here: "
643643
"https://github.com/Azure/azure-functions-durable-python/issues\n"
644-
f"maximumShortTimerDuration: {self.maximum_short_timer_duration}\n"
645-
f"longRunningTimerIntervalDuration: {self.long_timer_interval_duration}"
644+
f"maximumShortTimerDuration: {self._maximum_short_timer_duration}\n"
645+
f"longRunningTimerIntervalDuration: {self._long_timer_interval_duration}"
646646
)
647-
if fire_at > self.current_utc_datetime + self.maximum_short_timer_duration:
647+
if fire_at > self.current_utc_datetime + self._maximum_short_timer_duration:
648648
action = CreateTimerAction(fire_at)
649649
return LongTimerTask(None, action, self)
650650

azure/durable_functions/models/Task.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def try_set_value(self, child: TaskBase):
321321
class LongTimerTask(WhenAllTask):
322322
"""A Timer Task for intervals longer than supported by the storage backend."""
323323

324-
def __init__(self, id, action: CreateTimerAction, orchestration_context):
324+
def __init__(self, id_, action: CreateTimerAction, orchestration_context):
325325
"""Initialize a LongTimerTask.
326326
327327
Parameters
@@ -337,20 +337,20 @@ def __init__(self, id, action: CreateTimerAction, orchestration_context):
337337
final_fire_time = action.fire_at
338338
duration_until_fire = final_fire_time - current_time
339339

340-
if duration_until_fire > orchestration_context.maximum_short_timer_duration:
341-
next_fire_time = current_time + orchestration_context.long_timer_interval_duration
340+
if duration_until_fire > orchestration_context._maximum_short_timer_duration:
341+
next_fire_time = current_time + orchestration_context._long_timer_interval_duration
342342
else:
343343
next_fire_time = final_fire_time
344344

345345
next_timer_action = CreateTimerAction(next_fire_time)
346346
next_timer_task = TimerTask(None, next_timer_action)
347347
super().__init__([next_timer_task], orchestration_context._replay_schema)
348348

349-
self.id = id
349+
self.id = id_
350350
self.action = action
351-
self.orchestration_context = orchestration_context
352-
self.maximum_short_timer_duration = self.orchestration_context.maximum_short_timer_duration
353-
self.long_timer_interval_duration = self.orchestration_context.long_timer_interval_duration
351+
self._orchestration_context = orchestration_context
352+
self._max_short_timer_duration = self._orchestration_context._maximum_short_timer_duration
353+
self._long_timer_interval = self._orchestration_context._long_timer_interval_duration
354354

355355
def is_canceled(self) -> bool:
356356
"""Check if the LongTimer is cancelled.
@@ -385,7 +385,7 @@ def try_set_value(self, child: TimerTask):
385385
child : TimerTask
386386
A timer sub-task that just completed
387387
"""
388-
current_time = self.orchestration_context.current_utc_datetime
388+
current_time = self._orchestration_context.current_utc_datetime
389389
final_fire_time = self.action.fire_at
390390
if final_fire_time > current_time:
391391
next_timer = self.get_next_timer_task(final_fire_time, current_time)
@@ -408,8 +408,8 @@ def get_next_timer_task(self, final_fire_time: datetime, current_time: datetime)
408408
A TimerTask representing the next interval of the LongTimer
409409
"""
410410
duration_until_fire = final_fire_time - current_time
411-
if duration_until_fire > self.maximum_short_timer_duration:
412-
next_fire_time = current_time + self.long_timer_interval_duration
411+
if duration_until_fire > self._max_short_timer_duration:
412+
next_fire_time = current_time + self._long_timer_interval
413413
else:
414414
next_fire_time = final_fire_time
415415
return TimerTask(None, CreateTimerAction(next_fire_time))
@@ -426,8 +426,8 @@ def add_new_child(self, child_timer: TimerTask):
426426
"""
427427
child_timer.parent = self
428428
self.pending_tasks.add(child_timer)
429-
self.orchestration_context._add_to_open_tasks(child_timer)
430-
self.orchestration_context._add_to_actions(child_timer.action_repr)
429+
self._orchestration_context._add_to_open_tasks(child_timer)
430+
self._orchestration_context._add_to_actions(child_timer.action_repr)
431431
child_timer._set_is_scheduled(True)
432432

433433

tests/tasks/test_long_timers.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,28 @@ def test_long_timer_fires_appropriately(starting_context_v3):
4343
starting_time = starting_context_v3.current_utc_datetime
4444
final_fire_time = starting_time + datetime.timedelta(hours=20)
4545
long_timer_action = CreateTimerAction(final_fire_time)
46-
long_timer_task = LongTimerTask(None, long_timer_action, starting_context_v3)
47-
assert long_timer_task.action.fire_at == final_fire_time
48-
assert long_timer_task.action == long_timer_action
46+
long_timer = LongTimerTask(None, long_timer_action, starting_context_v3)
47+
assert long_timer.action.fire_at == final_fire_time
48+
assert long_timer.action == long_timer_action
4949

5050
# Check the first "inner" timer and simulate firing it
51-
short_timer_task = long_timer_task.pending_tasks.pop()
52-
assert short_timer_task.action_repr.fire_at == starting_time + datetime.timedelta(hours=8)
51+
short_timer = long_timer.pending_tasks.pop()
52+
assert short_timer.action_repr.fire_at == starting_time + datetime.timedelta(hours=8)
5353
# This happens when the task is reconstructed during replay, doing it manually for the test
54-
long_timer_task.orchestration_context.current_utc_datetime = short_timer_task.action_repr.fire_at
55-
short_timer_task.state = TaskState.SUCCEEDED
56-
long_timer_task.try_set_value(short_timer_task)
54+
long_timer._orchestration_context.current_utc_datetime = short_timer.action_repr.fire_at
55+
short_timer.state = TaskState.SUCCEEDED
56+
long_timer.try_set_value(short_timer)
5757

58-
assert long_timer_task.state == TaskState.RUNNING
58+
assert long_timer.state == TaskState.RUNNING
5959

6060
# Check the scond "inner" timer and simulate firing it. This one should be set to the final
6161
# fire time, the remaining time (12 hours) is less than the max long timer duration (16 hours)
62-
short_timer_task = long_timer_task.pending_tasks.pop()
63-
assert short_timer_task.action_repr.fire_at == final_fire_time
64-
long_timer_task.orchestration_context.current_utc_datetime = short_timer_task.action_repr.fire_at
65-
short_timer_task.state = TaskState.SUCCEEDED
66-
long_timer_task.try_set_value(short_timer_task)
62+
short_timer = long_timer.pending_tasks.pop()
63+
assert short_timer.action_repr.fire_at == final_fire_time
64+
long_timer._orchestration_context.current_utc_datetime = short_timer.action_repr.fire_at
65+
short_timer.state = TaskState.SUCCEEDED
66+
long_timer.try_set_value(short_timer)
6767

6868
# Ensure the LongTimerTask finished
69-
assert len(long_timer_task.pending_tasks) == 0
70-
assert long_timer_task.state == TaskState.SUCCEEDED
69+
assert len(long_timer.pending_tasks) == 0
70+
assert long_timer.state == TaskState.SUCCEEDED

0 commit comments

Comments
 (0)