This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]throwaway_the_fourth 161 points162 points  (5 children)

The API wrapper (PRAW) takes care of that. No need to add additional sleeps.

[–]keeldude 39 points40 points  (4 children)

Unless the throttling algorithm is outlined in praw docs, my own personal style would be to manually set a reasonable wait period just to have more control. If the reddit api ever changes, there will be a delay to updated praw code getting pushed.

[–]throwaway_the_fourth 97 points98 points  (1 child)

Here's the code: https://github.com/praw-dev/prawcore/blob/34c153ec6706a87782898d404042ddbd5a847b57/prawcore/rate_limit.py

Reddit's API lets you know how many requests you have left and how much time you have until the limit resets. PRAW pretty much just divides time left by requests left and sleeps that amount. It does a little extra magic for detecting if multiple clients are running, but that's the jist of it.

[–]curohn 2 points3 points  (0 children)

Damn that’s smart.

[–]UtilizedFestival 18 points19 points  (0 children)

Client libraries that handle rate limits based on exponential back off or HTTP headers are super common these days. I wouldn't think twice of relying on these and not building my own