MaineKuehn/usim

Iterating time by delay or interval is inconsistent

maxfischer2781 opened this issue · 2 comments

The time iterators IntervalIter and DurationIter, and by extension each, treat the first time interval differently. In an async for now in each(...)::

  • IntervalIter starts at the time at which each was entered
  • DurationIter starts after each has enter and one delay has passed
start_time = time.now
async for now in each(...):
    assert now == start_time  # True for IntervalIter, False for DurationIter

Any suggestion how we want to tackle this? Should it be true or false for both of them? Or is even the definition of interval and duration different, that this is expected behaviour?

For duration, I expect false. I also slightly expect false for iteration.
What about you?

I am also slightly in favour of False for both. It is trivial to manually add a non-delayed block, but difficult to skip a delayed one.

body()
async for now in each(...):  # assuming false
    body()
first = True
async for now in each(...):  # assuming true
    if first:
        first = False
        continue
    body()