0

Just wondering whether my idea is unnecessarily complicated and if there is an easier/better way.

I'm planning on using Celery to send requests and retrieve data from a rate limited RESTful API (10 requests per 10 seconds). This was the solution to an issue I came upon earlier where my self written api wrapper, which handled the rate limit internally, would be instanced for each view and therefore incorrectly handle the rate limit.

Edit (More details):
I'm creating a website that has to request data from a RESTful API (namely League of Legends' API). I've written a python wrapper for the API, which deals with the rate limit imposed by the API by counting the requests made per interval and waiting. However when it came to implementing my wrapper into my Django project, I realised that creating an instance of my wrapper class when I need to utilise the API would break the rate limit handling of my wrapper as each instance would have a separate count of requests.

The solution I thought of, that may or may not be too complex, is to use Celery to 'run' a single instance of my wrapper that every view would use. This seemed relatively 'out of the way' for a idea that seemed pretty simple. Perhaps there is a simpler way to carry a single instance of a class throughout.

Nami
  • 1
  • 1

0 Answers0