clockblocks.utilities.sleep_precisely_until

clockblocks.utilities.sleep_precisely_until(stop_time: float, interruption_event: Optional[Event] = None) None[source]

High-precision sleep until stop_time. Sleeps repeatedly by half of the remaining time until there are fewer than 500 microseconds left, at which point it implements a busy wait.

Parameters:
  • stop_time – desired stop time in seconds since the epoch (as is returned by time.time())

  • interruption_event – (optional) an Event used to execute the sleep call. This has the advantage that the sleep can be interrupted by calling set() on the event.