Skip to content

Instantly share code, notes, and snippets.

@jarhill0
Created May 28, 2020 00:03
Show Gist options
  • Save jarhill0/384458102d89993b41e62804d445c5ff to your computer and use it in GitHub Desktop.
Save jarhill0/384458102d89993b41e62804d445c5ff to your computer and use it in GitHub Desktop.
Test Reddit ratelimit usage rate — runs for 60 seconds without output and then exits
from time import monotonic
import praw
reddit = praw.Reddit(...) # authenticate
print(f'Authenticated as {reddit.user.me()}')
start_time = monotonic()
used_at_start = reddit._core._rate_limiter.used
for submission in reddit.subreddit("all").stream.submissions():
if monotonic() - start_time > 60:
break
used_at_end = reddit._core._rate_limiter.used
print(f"{used_at_end - used_at_start} requests made in 60 seconds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment