code: def general_error_sleeper(api, response, sleep=300):
      
      while response.status_code >= 500:
          logger.warning('Caught [%s] status code! Waiting for [%s]s',
                         response.status_code, sleep)
          time.sleep(sleep)
          response = api.session.send(response.request)
      return response
docs: Pauses the execution if response status code is > 500.
      :param api: Api instance.
      :param response: requests.Response object
      :param sleep: Time to sleep in between the requests.