(self, wake_time)
Sleeps until the requested time.
Sleeps until the requested time.
Sleeps until the requested time .
def sleep_until(self, wake_time):
    """Sleeps until the requested time."""
    delta = wake_time - time.time()

    if delta <= 0:
      return

    # Copy the current offset, since it might change.
    offset_ = self.offset

    if delta > offset_:
      time.sleep(delta - offset_)

    remaining_time = time.time() - wake_time
    # Enter critical section for updating the offset.
    with self._lock:
      # Only update if the current offset value is what was used in this call.
      if self.offset == offset_:
        offset_delta = (offset_ - Sleeper._MIN_OFFSET) / 2
        if remaining_time > 0:
          self.offset -= offset_delta
        elif remaining_time < -Sleeper._MIN_OFFSET:
          self.offset += offset_delta

    while time.time() < wake_time:
      pass
def sleep_until ( self , wake_time ) : delta = wake_time - time . time ( ) if delta <= 0 : return # Copy the current offset, since it might change. offset_ = self . offset if delta > offset_ : time . sleep ( delta - offset_ ) remaining_time = time . time ( ) - wake_time # Enter critical section for updating the offset. with self . _lock : # Only update if the current offset value is what was used in this call. if self . offset == offset_ : offset_delta = ( offset_ - Sleeper . _MIN_OFFSET ) / 2 if remaining_time > 0 : self . offset -= offset_delta elif remaining_time < - Sleeper . _MIN_OFFSET : self . offset += offset_delta while time . time ( ) < wake_time : pass