diff --git a/eventkit/ops/timing.py b/eventkit/ops/timing.py index 844368f..a9fb770 100644 --- a/eventkit/ops/timing.py +++ b/eventkit/ops/timing.py @@ -44,6 +44,7 @@ def __init__(self, timeout, source=None): def on_source(self, *args): loop = get_event_loop() self._last_time = loop.time() + Op.on_source(self, *args) def on_source_done(self, source): self._handle.cancel() diff --git a/tests/timing_test.py b/tests/timing_test.py index 77cbbe3..c47391a 100644 --- a/tests/timing_test.py +++ b/tests/timing_test.py @@ -23,6 +23,13 @@ def test_sample(self): self.assertEqual(event.run(), [2, 4, 6, 8]) def test_timeout(self): + # source faster than timeout + seq = Event.sequence(array1, interval=0.01).timeout(0.1) + self.assertEqual(seq.run(), array1) + # source slower than timeout + seq2 = Event.sequence([1, 2, 3], interval=0.1).timeout(0.01) + self.assertEqual(seq2.run(), [1, Event.NO_VALUE]) + # plain timeout timer = Event.timer(10, count=1) event = timer.timeout(0.01) self.assertEqual(event.run(), [Event.NO_VALUE])