Hi ! I really dont understand how to rate_limit a ...
# ask-community
l
Hi ! I really dont understand how to rate_limit a task to prevent hitting api rate limit ?
I have this task :
Copy code
@task 
	def request(self, endpoint: str, params: dict = {}) -> dict:
		# rate_limit("tmdb-api")
		self.api_key = self._get_next_api_key()
		url = f"{self.base_url}/{endpoint}"
		params["api_key"] = self.api_key
		response = requests.get(url, params=params)
		response.raise_for_status()
		data = response.json()
		if "success" in data and not data["success"]:
			raise ValueError(f"Failed to get data from TMDB: {data}")
		return data
How can I do the prevent hitting the rate limit of TMDB API ? (which is 50 requests per second
I really dont understand what I have to set here :
Because without the
rate_limit("tmdb-api")
my script is very fast, 14s for making 150 api requests which is way below the rate limit. But with rate_limit enable what ever the value I set its around 40s, just why ?
I really dont understand
I really need to fix my script who take wayy too much time because of the 'rate_limit' any idea ?