code: def _ratelimit(self, http_method, url, **kwargs):
          
  
          def time_since_last_call():
              if self.callsafety['lastcalltime'] is not None:
                  return int(time() - self.callsafety['lastcalltime'])
              else:
                  return None
  
          lastlimitremaining = self.callsafety['lastlimitremaining']
  
          if time_since_last_call() is None or time_since_last_call() >= self.ratelimit_request_interval or \
                  lastlimitremaining >= self.ratelimit:
              response = http_method(url, **kwargs)
          else:
              # We hit our limit floor and aren't quite at ratelimit_request_interval value in seconds yet..
              log.warning(
                  "Safety Limit Reached of %s remaining calls and time since last call is under %s seconds"
                  % (self.ratelimit, self.ratelimit_request_interval)
              )
              while time_since_last_call() < self.ratelimit_request_interval:
                  remaining_sleep = int(self.ratelimit_request_interval - time_since_last_call())
                  log.debug("  -> sleeping: %s more seconds" % remaining_sleep)
                  self.check_ratelimit_budget(1)
                  sleep(1)
              response = http_method(url, **kwargs)
  
          self.callsafety['lastcalltime'] = time()
          self.callsafety['lastlimitremaining'] = int(response.headers.get('X-Rate-Limit-Remaining', 0))
          return response
docs: Ensure we do not hit the rate limit.