code: def exponential_backoff(fn, sleeptime_s_max=30 * 60):
      
  
      sleeptime_ms = 500
      while True:
          if fn():
              return True
          else:
              print('Sleeping {} ms'.format(sleeptime_ms))
              time.sleep(sleeptime_ms / 1000.0)
              sleeptime_ms *= 2
  
          if sleeptime_ms / 1000.0 > sleeptime_s_max:
              return False
docs: Calls `fn` until it returns True, with an exponentially increasing wait time between calls