Skip to content

Commit 7829ee6

Browse files
committed
Retry with generator.
1 parent 70fe459 commit 7829ee6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

wscodec/decoder/hdc2021.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
class TempSample(Sample):
6-
def __init__(self, rawtemp: int, timestamp: datetime = None):
6+
def __init__(self, rawtemp: int, timestamp: datetime):
77
"""
88
99
:param rawtemp:
@@ -23,7 +23,7 @@ def reading_to_temp(reading: int) -> float:
2323

2424

2525
class TempRHSample(TempSample):
26-
def __init__(self, rawtemp: int, rawrh: int, timestamp: datetime = None):
26+
def __init__(self, rawtemp: int, rawrh: int, timestamp: datetime):
2727
super().__init__(rawtemp, timestamp)
2828
self.rawrh = rawrh
2929
self.rh = self.reading_to_rh(rawrh)
@@ -67,7 +67,7 @@ def __init__(self, *args, **kwargs):
6767

6868
for pair in self.pairs:
6969
if pair.rd1 != 4095:
70-
sample = TempSample(pair.rd1)
70+
sample = TempSample(pair.rd1, timestamp=next(timestamp_gen))
7171
self.samples.append(sample)
7272

7373
sample = TempSample(pair.rd0, timestamp=next(timestamp_gen))

wscodec/decoder/samples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ def generate_timestamp(self):
7676
7777
"""
7878
sampleindex = 0
79-
while sampleindex < len(self.samples):
79+
while 1:
8080
yield self.newest_timestamp - sampleindex * self.timeinterval
8181
sampleindex = sampleindex + 1

0 commit comments

Comments
 (0)