Skip to content

Commit d806bf4

Browse files
committed
Move private method to the end of the class
This is only to make it easier to read the class, having the public methods first and then the private ones. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 5ce3f7d commit d806bf4

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/frequenz/sdk/timeseries/_resampling.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -428,30 +428,6 @@ def remove_timeseries(self, source: Source) -> bool:
428428
return False
429429
return True
430430

431-
async def _wait_for_next_resampling_period(self) -> None:
432-
"""Wait for next resampling period.
433-
434-
If resampling period already started, then return without sleeping.
435-
That would allow us to catch up with resampling.
436-
Print warning if function woke up to late.
437-
"""
438-
now = datetime.now(tz=timezone.utc)
439-
if self._window_end > now:
440-
sleep_for = self._window_end - now
441-
await asyncio.sleep(sleep_for.total_seconds())
442-
443-
timer_error_s = (now - self._window_end).total_seconds()
444-
if timer_error_s > (self._config.resampling_period_s / 10.0):
445-
_logger.warning(
446-
"The resampling task woke up too late. Resampling should have started "
447-
"at %s, but it started at %s (%s seconds difference; resampling "
448-
"period is %s seconds)",
449-
self._window_end,
450-
now,
451-
timer_error_s,
452-
self._config.resampling_period_s,
453-
)
454-
455431
async def resample(self, *, one_shot: bool = False) -> None:
456432
"""Start resampling all known timeseries.
457433
@@ -493,6 +469,30 @@ async def resample(self, *, one_shot: bool = False) -> None:
493469
if one_shot:
494470
break
495471

472+
async def _wait_for_next_resampling_period(self) -> None:
473+
"""Wait for next resampling period.
474+
475+
If resampling period already started, then return without sleeping.
476+
That would allow us to catch up with resampling.
477+
Print warning if function woke up to late.
478+
"""
479+
now = datetime.now(tz=timezone.utc)
480+
if self._window_end > now:
481+
sleep_for = self._window_end - now
482+
await asyncio.sleep(sleep_for.total_seconds())
483+
484+
timer_error_s = (now - self._window_end).total_seconds()
485+
if timer_error_s > (self._config.resampling_period_s / 10.0):
486+
_logger.warning(
487+
"The resampling task woke up too late. Resampling should have started "
488+
"at %s, but it started at %s (%s seconds difference; resampling "
489+
"period is %s seconds)",
490+
self._window_end,
491+
now,
492+
timer_error_s,
493+
self._config.resampling_period_s,
494+
)
495+
496496

497497
class _ResamplingHelper:
498498
"""Keeps track of *relevant* samples to pass them to the resampling function.

0 commit comments

Comments
 (0)