Skip to content

Commit a31fdcf

Browse files
committed
Add a wall clock attached timer for the resampler
This timer uses the wall clock to trigger ticks and handles discrepancies between the wall clock and monotonic time. Since sleeping is performed using monotonic time, differences between the two clocks can occur. When the wall clock progresses slower than monotonic time, it is referred to as *compression* (wall clock time appears in the past relative to monotonic time). Conversely, when the wall clock progresses faster, it is called *expansion* (wall clock time appears in the future relative to monotonic time). If these differences exceed a configured threshold, a warning is emitted. If the difference becomes excessively large, it is treated as a *time jump*. Time jumps can occur, for example, when the wall clock is adjusted by NTP after being out of sync for an extended period. In such cases, the timer resynchronizes with the wall clock and triggers an immediate tick. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent f3d594e commit a31fdcf

File tree

2 files changed

+856
-0
lines changed

2 files changed

+856
-0
lines changed

src/frequenz/sdk/timeseries/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,16 @@
4343
from ._resampling._base_types import SourceProperties
4444
from ._resampling._config import ResamplerConfig, ResamplingFunction
4545
from ._resampling._exceptions import ResamplingError, SourceStoppedError
46+
from ._resampling._wall_clock_timer import (
47+
ClocksInfo,
48+
TickInfo,
49+
WallClockTimer,
50+
WallClockTimerConfig,
51+
)
4652

4753
__all__ = [
4854
"Bounds",
55+
"ClocksInfo",
4956
"Fuse",
5057
"MovingWindow",
5158
"PeriodicFeatureExtractor",
@@ -57,4 +64,7 @@
5764
"Sample3Phase",
5865
"SourceProperties",
5966
"SourceStoppedError",
67+
"TickInfo",
68+
"WallClockTimer",
69+
"WallClockTimerConfig",
6070
]

0 commit comments

Comments
 (0)