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.
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.