xdevplatform / Twitter-API-v2-sample-code

Sample code for the Twitter API v2 endpoints
https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api
Apache License 2.0
2.66k stars 985 forks source link

Handled ChunkedEncodingError in filtered_stream.py #36

Open pranftw opened 3 years ago

pranftw commented 3 years ago

ChunkedEncodingError was raised every 5 mins due to some issue with the servers that the requests module couldn't handle. The request to get the stream was wrapped in a try-except block and the entire code in get_stream is made to run forever using while(True):. Whenever a KeyboardInterrupt is raised using ctrl + C, the program and the stream gets suspended. When a ChunkedEncodingError is caught, the program execution continues with continue, thus causing the new request to the stream to be made automatically whenever ChunkedEncodingError is raised and caught. Finally any other Exceptions will be raised.

TO THE MAINTAINERS This is my first pull request on GitHub on any repo. So please excuse me if I did not follow the proper format for this pull request. I've tested the code, in case you had any doubts regarding that. Thanks!

twitterAPI

github-actions[bot] commented 3 years ago

CLA Assistant Lite bot All Contributors have signed the CLA. If the commit check is not passing, a maintainer must go the Checks tab of this PR and rerun the GitHub Action.

pranftw commented 3 years ago

I have read the CLA Document and I hereby sign the CLA

pranftw commented 3 years ago

recheck

pranftw commented 3 years ago

recheck

pranftw commented 3 years ago

I have read the CLA Document and I hereby sign the CLA