Skip to content

[th/loop_sleep] add and use "loop_sleep()" helper with nmci.util.start_timeout()

Thomas Haller requested to merge th/loop_sleep into main

add a helper for looping while we wait for a timeout.

I think it makes the code easier to read (it certainly requires fewer lines of code, which can indicate that it's easier to read). It also avoids common pitfalls (or things that are cumbersome to workaround to ensure not to happen)

  • when called with a very short timeout, ensure that the loop runs at least once.
  • the last timeout is truncated to not wait too long. If your sleep granularity is large, then we won't wait for the full last timeout.

For how it's used, see the second commit that makes use of it.

Merge request reports