Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suddenly failing #164

Open
mkaatman opened this issue Mar 30, 2021 · 11 comments
Open

Suddenly failing #164

mkaatman opened this issue Mar 30, 2021 · 11 comments

Comments

@mkaatman
Copy link

Traceback (most recent call last):
  File "/home/user/.local/bin/shreddit", line 8, in <module>
    sys.exit(main())
  File "/home/user/.local/lib/python3.8/site-packages/shreddit/app.py", line 54, in main
    shredder.shred()
  File "/home/user/.local/lib/python3.8/site-packages/shreddit/shredder.py", line 68, in shred
    deleted = self._remove_things(self._build_iterator())
  File "/home/user/.local/lib/python3.8/site-packages/shreddit/shredder.py", line 171, in _remove_things
    self._remove(item)
  File "/home/user/.local/lib/python3.8/site-packages/shreddit/shredder.py", line 142, in _remove
    self._remove_comment(item)
  File "/home/user/.local/lib/python3.8/site-packages/shreddit/shredder.py", line 128, in _remove_comment
    comment.edit(replacement_text)
  File "/home/user/.local/lib/python3.8/site-packages/praw/models/reddit/mixins/editable.py", line 47, in edit
    updated = self._reddit.post(API_PATH["edit"], data=data)[0]
  File "/home/user/.local/lib/python3.8/site-packages/praw/reddit.py", line 665, in post
    return self._objectify_request(
  File "/home/user/.local/lib/python3.8/site-packages/praw/reddit.py", line 578, in _objectify_request
    self.request(
  File "/home/user/.local/lib/python3.8/site-packages/praw/reddit.py", line 758, in request
    return self._core.request(
  File "/home/user/.local/lib/python3.8/site-packages/prawcore/sessions.py", line 332, in request
    return self._request_with_retries(
  File "/home/user/.local/lib/python3.8/site-packages/prawcore/sessions.py", line 268, in _request_with_retries
    assert (
AssertionError: Unexpected status code: 429

@endeavor51
Copy link

Reddit introduced rate-limiting on their API about 4 days ago. Rumor has it it was due to a bot earlier this week who edited comments with the usernames of every Reddit account to spam chat requests.

Current API limitations have write actions (post/edit) limited to 1 every 30 seconds. This isn't limited to apps, even old.reddit.com/ blocks users in the interface from editing more than once every 30 sec.

To fix, Shreddit will need to add a delay timer, hopefully with a programmable variable to be included in shreddit.yml.

Unfortunately, I think the app is no longer in development, so here's hoping some fork fixes it.

@endeavor51
Copy link

@scottjl
Copy link

scottjl commented Mar 30, 2021

i'm still getting it.. any idea where to add the delay?

@endeavor51
Copy link

I haven't had time to look at the code (never was very good with Python). I tried manipulating the cooldown feature unsuccessfully.

An maintained fork of Shreddit is available here: https://github.com/pythonInRelay/Shreddit But that fork doesn't have a fix for this yet either.

@diversionmary
Copy link

See here: https://github.com/pythonInRelay/Shreddit/issues/9

Add ratelimit_seconds=45 to your praw.ini within your username section. I also added to a [default] section at the top of my praw.ini. thx to @KenMacD

@xb4r7x
Copy link

xb4r7x commented Mar 31, 2021

And if you're like me, and ratelimit_seconds=45 didn't do anything, make sure your praw is up to date. pip3 install --upgrade praw and you should be g2g.

@benninkcorien
Copy link

rate_limit_seconds in praw.ini didn't help me.

I added a few

time.sleep(4) 

to shredder.py so that it sleeps for 4 seconds after each edit. That seems to have fixed it. It just takes a little longer now.
(shredder.py is located in C:\Users\USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages\shreddit on windows)

@xb4r7x
Copy link

xb4r7x commented May 11, 2021

Did you make sure that praw was up to date? The rate_limit_seconds thing only works in more recent versions. Your work around works, but is kinda silly when the functionality is already baked in.

@benninkcorien
Copy link

benninkcorien commented May 11, 2021

I installed everything today, but didn't check the praw version in requirements.text - will see if I can update, thank you!

Edit - went from v5x to v7x ... I've already ran shreddit so can't test at the moment, but I'll assume setting the rate limit in praw.ini works better.

@phayzeeVW
Copy link

phayzeeVW commented Jun 10, 2021

I also ran into this problem today. praw version is up-to-date, rate_limit_seconds = 45 is set in praw.ini, but I can't still run it.
it seems that adding time.sleep(4) works, but it is very slow.

EDIT: changed time.sleep(4) to time.sleep(2) to speed-up the process and it works just fine

@scottjl
Copy link

scottjl commented Jun 10, 2021

strange. the delay time must somehow be tied to the reddit account itself. other than adjusting mine from 31 to 45 i haven't made any other changes and it runs just fine. i run it once a night at 2am via cron. it sweeps up messages and posts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants