code: def _wait_time(self, shard_state, secs, now=datetime.datetime.now):
      
      assert shard_state.slice_start_time is not None
      delta = now() - shard_state.slice_start_time
      duration = datetime.timedelta(seconds=secs)
      if delta < duration:
        return util.total_seconds(duration - delta)
      else:
        return 0
docs: Time to wait until slice_start_time is secs ago from now.
  
      Args:
        shard_state: shard state.
        secs: duration in seconds.
        now: a func that gets now.
  
      Returns:
        0 if no wait. A positive int in seconds otherwise. Always around up.