Skip to content

Commit 8bf090f

Browse files
committed
Limit missing logs collection to MAX_LOG_HOURS time period
1 parent 0eb975d commit 8bf090f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugwise_usb/nodes/helpers/pulses.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,13 @@ def _logs_missing(self, from_timestamp: datetime) -> list[int] | None:
893893
return None
894894

895895
# Collect any missing address in current range
896+
count = 0
896897
address = last_address
897898
slot = last_slot
898-
while not (address == first_address and slot == first_slot):
899+
while not (
900+
(address == first_address and slot == first_slot)
901+
or count > MAX_LOG_HOURS
902+
):
899903
address, slot = calc_log_address(address, slot, -1)
900904
if address in missing:
901905
continue
@@ -905,6 +909,8 @@ def _logs_missing(self, from_timestamp: datetime) -> list[int] | None:
905909
if self._logs[address][slot].timestamp <= from_timestamp:
906910
break
907911

912+
count += 1
913+
908914
# return missing logs in range first
909915
if len(missing) > 0:
910916
_LOGGER.debug(

0 commit comments

Comments
 (0)