praw-dev / praw

PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.
http://praw.readthedocs.io/
BSD 2-Clause "Simplified" License
3.47k stars 456 forks source link

Issue with Rate limits causing fatal error #1954

Closed andyb2000 closed 1 year ago

andyb2000 commented 1 year ago

Describe the Documentation Issue

Reading documentation for submitting to a subreddit: https://praw.readthedocs.io/en/stable/getting_started/ratelimits.html

In the initial creation of object I set ratelimit_seconds=300 like this:

reddit = praw.Reddit(
    client_id="xx",
    client_secret="xx",
    user_agent="xx-app",
    username='xx',
    password='xx,',
    ratelimit_seconds=300
)

However, when trying to submit to a subreddit like this:

post_obj = reddit.subreddit("subred").submit("my post title here", url="https:// url to image")

If I send two or 3 in a row I then get the whole python script abort due to:

Traceback (most recent call last):
<SNIP>
    raise RedditAPIException(errors)
praw.exceptions.RedditAPIException: RATELIMIT: "Looks like you've been doing that a lot. Take a break for 14 minutes before trying again." on field 'ratelimit'

This is contrary to the suggestion on ratelimits.html suggesting praw will wait for the set seconds, etc. Is this a documentation error, should we always try/catch errors and handle the "You're doing that too much. Try again in 3 minutes." ourselves as it suggests praw should be handling this?

Attributes

Location of the issue

https://praw.readthedocs.io/en/stable/getting_started/ratelimits.html

What did you expect to see?

How to use ratelimits correctly, either via try/catch exceptions or via PRAW

What did you actually see?

Exception/script abort

Proposed Fix

No response

Operating System/Web Browser

No response

Anything else?

No response

LilSpazJoekp commented 1 year ago

ratelimit_seconds must be >= the time shown in the error. In this case it is 14 minutes instead of the 5 minutes you specified.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

Remove the Stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stale for 30 days with no activity.