original_docstring: \
          Wait for func() to return zero with exponential backoff
          
docstring: \
  Wait for func() to return zero with exponential backoff
docstring_tokens: \ Wait for func () to return zero with exponential backoff
code: def waitfor(self, func, attempts = 10, maxretrydelay = 0.25):
          '''\
          Wait for func() to return zero with exponential backoff
          '''
          delay = 0.01
          for i in xrange(1, attempts + 1):
              r = func()
              if r == 0:
                  return
              msg = 'attempt %s failed with nonzero exit status %s' % (i, r)
              if i < attempts + 1:
                  msg += ', retrying...'
                  self.node.info(msg)
                  time.sleep(delay)
                  delay = delay + delay
                  if delay > maxretrydelay:
                      delay = maxretrydelay
              else:
                  msg += ', giving up'
                  self.node.info(msg)
          raise RuntimeError, 'command failed after %s attempts' % attempts
code_tokens: def waitfor ( self , func , attempts = 10 , maxretrydelay = 0.25 ) : delay = 0.01 for i in xrange ( 1 , attempts + 1 ) : r = func ( ) if r == 0 : return msg = 'attempt %s failed with nonzero exit status %s' % ( i , r ) if i < attempts + 1 : msg += ', retrying...' self . node . info ( msg ) time . sleep ( delay ) delay = delay + delay if delay > maxretrydelay : delay = maxretrydelay else : msg += ', giving up' self . node . info ( msg ) raise RuntimeError , 'command failed after %s attempts' % attempts
short_docstring: \
  Wait for func() to return zero with exponential backoff
short_docstring_tokens: \ Wait for func () to return zero with exponential backoff
comment: '''\
          Wait for func() to return zero with exponential backoff
          '''