Skip to content

Commit 99971c9

Browse files
author
Rares Polenciuc
committed
feat: add DURABLE_EXECUTION_TIME_SCALE env var for wait scaling
1 parent fea8882 commit 99971c9

File tree

2 files changed

+10
-4
lines changed
  • src/aws_durable_execution_sdk_python_testing

2 files changed

+10
-4
lines changed

src/aws_durable_execution_sdk_python_testing/checkpoint/processors/wait.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import annotations
44

5+
import logging
6+
import os
57
from datetime import UTC, datetime, timedelta
68
from typing import TYPE_CHECKING
79

@@ -41,8 +43,12 @@ def process(
4143
wait_seconds = (
4244
update.wait_options.wait_seconds if update.wait_options else 0
4345
)
46+
time_scale = float(os.getenv("DURABLE_EXECUTION_TIME_SCALE", "1.0"))
47+
logging.info("Using DURABLE_EXECUTION_TIME_SCALE: %f", time_scale)
48+
scaled_wait_seconds = wait_seconds * time_scale
49+
4450
scheduled_end_timestamp = datetime.now(UTC) + timedelta(
45-
seconds=wait_seconds
51+
seconds=scaled_wait_seconds
4652
)
4753

4854
# Create WaitDetails with scheduled timestamp
@@ -72,7 +78,7 @@ def process(
7278
notifier.notify_wait_timer_scheduled(
7379
execution_arn=execution_arn,
7480
operation_id=update.operation_id,
75-
delay=wait_seconds,
81+
delay=scaled_wait_seconds,
7682
)
7783
return wait_operation
7884
case OperationAction.CANCEL:

src/aws_durable_execution_sdk_python_testing/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,7 @@ def create_wait_event_started(cls, context: EventCreationContext) -> Event:
17601760
and wait_details.scheduled_end_timestamp
17611761
and context.operation.start_timestamp
17621762
):
1763-
duration = int(
1763+
duration = round(
17641764
(
17651765
wait_details.scheduled_end_timestamp
17661766
- context.operation.start_timestamp
@@ -1789,7 +1789,7 @@ def create_wait_event_succeeded(cls, context: EventCreationContext) -> Event:
17891789
and wait_details.scheduled_end_timestamp
17901790
and context.operation.start_timestamp
17911791
):
1792-
duration = int(
1792+
duration = round(
17931793
(
17941794
wait_details.scheduled_end_timestamp - context.start_timestamp
17951795
).total_seconds()

0 commit comments

Comments
 (0)