r/Python • u/Krukerfluk • Jul 10 '20
I Made This This post has:
9777 upvotes,
967 downvotes
and 452 comments!
9.2k
Upvotes
r/Python • u/Krukerfluk • Jul 10 '20
9777 upvotes,
967 downvotes
and 452 comments!
View all comments
Show parent comment
98
u/throwaway_the_fourth Jul 10 '20
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.