Skip to content

Rewind file streams before rate-limit retries#2179

Open
CR29-22-2805 wants to merge 1 commit into
praw-dev:mainfrom
CR29-22-2805:fix-2178-rewind-file-streams
Open

Rewind file streams before rate-limit retries#2179
CR29-22-2805 wants to merge 1 commit into
praw-dev:mainfrom
CR29-22-2805:fix-2178-rewind-file-streams

Conversation

@CR29-22-2805

Copy link
Copy Markdown

Summary

Rewind seekable multipart file streams before retrying a POST request after a retryable RATELIMIT response.

Without rewinding, the first request consumes the stream and a retry may upload an empty or truncated file.

Changes

  • Record the initial position of seekable file streams passed to Reddit.post()
  • Restore those positions before each retry
  • Leave non-seekable streams unchanged
  • Add a regression test covering a rate-limit retry with a partially advanced BytesIO stream

Fixes #2178

Tests

  • python -m pytest tests/unit/test_reddit.py -k post_ratelimit
  • python -m pytest tests/unit/test_reddit.py

@CR29-22-2805
CR29-22-2805 force-pushed the fix-2178-rewind-file-streams branch 3 times, most recently from 9a8cc7e to e9b0358 Compare July 20, 2026 04:10
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

Successfully merging this pull request may close these issues.

File uploads may be empty or truncated after a rate-limit retry

1 participant