def __exit__(self, type, value, traceback):
    '''Invoked at the end of with block.
       If exception happened, sleep for an exponentially extended amount of
       time and then the caller would raise the exception.
    '''
    if isinstance(value, Exception):
      self.err_count += 1
    else:
      self.err_count = 0

    delay = min((2 ** self.err_count) * self.delay, self.MAX_DELAY)
    if self.err_count > 0:
      print 'delay: %f' % delay

    time.sleep(delay)
    self.lock.release()
dataset/ETHPy150Open bloomreach/briefly/src/briefly/rate_limit_lock.py/RateLimitLock.__exit__/original