inbox.stream not returning None properly and instead heading into an unbreakable loop
See original GitHub issueDescribe the Bug
When running a inbox.stream(pause_after=-1) I’d expect it to:
- Fetch previous unread.
-
- Return None after is done.
-
- When next polled, if no data is received, should return None, but it does not, it instead starts decreasing limit from 100 to 75, then jumps to 100 and repeats the cycle
Desired Result
Desired result: For it to return None, rather than going down to 99, 98 etc
Relevant Logs
The very first request it does are like the below, but it uses before="t4_ANID", unfortunately it scrolls off my screen too quick for me to grab it.
DEBUG:prawcore:Response: 200 (8580 bytes)
DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/message/unread/
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'before': None, 'mark': False, 'limit': 96, 'raw_json': 1}
DEBUG:urllib3.connectionpool:https://oauth.reddit.com:443 "GET /message/unread/?mark=False&limit=96&raw_json=1 HTTP/1.1"
200 8580
DEBUG:prawcore:Response: 200 (8580 bytes)
DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/message/unread/
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'before': None, 'mark': False, 'limit': 95, 'raw_json': 1}
DEBUG:urllib3.connectionpool:https://oauth.reddit.com:443 "GET /message/unread/?mark=False&limit=95&raw_json=1 HTTP/1.1"
200 8580
DEBUG:prawcore:Response: 200 (8580 bytes)
DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/message/unread/
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'before': None, 'mark': False, 'limit': 94, 'raw_json': 1}
DEBUG:urllib3.connectionpool:https://oauth.reddit.com:443 "GET /message/unread/?mark=False&limit=94&raw_json=1 HTTP/1.1"
200 8580
DEBUG:prawcore:Response: 200 (8580 bytes)
DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/message/unread/
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'before': None, 'mark': False, 'limit': 93, 'raw_json': 1}
DEBUG:urllib3.connectionpool:https://oauth.reddit.com:443 "GET /message/unread/?mark=False&limit=93&raw_json=1 HTTP/1.1"
200 8580
DEBUG:prawcore:Response: 200 (8580 bytes)
DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/message/unread/
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'before': None, 'mark': False, 'limit': 92, 'raw_json': 1}
Code to reproduce the bug
def run_inbox(ist=0):
if(ist==0):
ist=g.reddit.inbox.stream(pause_after=-1)
for y in ist:
if(y==None):
break
# do stuff
return ist
My code example does not include the Reddit()
initialization to prevent credential leakage.
Yes
This code has previously worked as intended.
Yes
Operating System/Environment
Running on windows 10.
Python Version
3.8
PRAW Version
latest on pip
Prawcore Version
latest on pip
Anything else?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Function keeps returning None - Codecademy
Hello, My function keeps returning None instead of True or False. It seems it doesn't go in the for loop, but I don't...
Read more >Rob Landley's Blog Thing for 2022
I had a "git log" blocked on "less" in there, but the PROCESS that's running says it's git pack on the command line....
Read more >Every Lana Del Rey Song, Ranked: Critic's List - Billboard
Ranking all 113 of Lana Del Rey's individual songs allows a valuable opportunity to take a critical look at her entire body of...
Read more >- CONFIRMATION HEARING ON THE NOMINATION OF HON ...
BRETT M. KAVANAUGH TO BE AN ASSOCIATE JUSTICE OF THE SUPREME COURT OF THE ... 2921 Arnold, Carrie, ``Life After Rape: The Sexual...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep this fixed it. Sorry for the bother.
The problem is probably the creation of the stream inside the function, this only works well if the same stream object is reused.
Incrementing of the limit parameter is to help break caches.