Comments (4)
Handling rate limits is a big issue when it comes to paid requests. I hope it will be incorporated soon.
from search-tweets-python.
There appear to be different rate limits between the enterprise 30day and enterprise full archive search products. For my query, the code polls for new pages at a rate that exceeds 30 day but not FAS rate limits.
Full archive enterprise search doesn't hit rate limit:
(3.7.0) [tw-mbp-jkolb ~]$ search_tweets.py --credential-file-key enterprise_fas --filter-rule "kolb" | wc -l
5405
30-day enterprise search with max results set to limit pagination:
(3.7.0) [tw-mbp-jkolb ~]$ search_tweets.py --credential-file-key enterprise_30day --filter-rule "kolb" --max-results 1000 | wc -l
1000
30-day enterprise with no max results:
(3.7.0) [tw-mbp-jkolb ~]$ search_tweets.py --credential-file-key enterprise_30day --filter-rule "kolb" | wc -l ERROR:searchtweets.result_stream:HTTP Error code: 429: Exceeded rate limit ERROR:searchtweets.result_stream:Rule payload: {'query': 'kolb', 'next': 'eyJhdXRoZW50aWNpdHkiOiIzNDgxYWE1YmZlYzgyNDJlMjYxMjFkNDYyM2U5NjRlZTZlOWQ5Njk4MWI3YWYwZDdhYWNlYTUzZDhlZDU2ZWRkIiwiZnJvbURhdGUiOiIyMDE4MDgwODAwMDAiLCJ0b0RhdGUiOiIyMDE4MDkwNzE2MjYiLCJuZXh0IjoiMjAxODA4MjkyMTI5MTgtMTAzNDkxNTkyMzU3MDk3MDYyNi0wIn0='} Traceback (most recent call last): File "/Users/jkolb/python_installations/3.7.0/bin/search_tweets.py", line 6, in <module> exec(compile(open(__file__).read(), __file__, 'exec')) File "/Users/jkolb/repos/search-tweets-python/tools/search_tweets.py", line 196, in <module> main() File "/Users/jkolb/repos/search-tweets-python/tools/search_tweets.py", line 190, in main for tweet in stream: File "/Users/jkolb/repos/search-tweets-python/searchtweets/result_stream.py", line 216, in stream self.execute_request() File "/Users/jkolb/repos/search-tweets-python/searchtweets/result_stream.py", line 253, in execute_request rule_payload=self.rule_payload) File "/Users/jkolb/repos/search-tweets-python/searchtweets/result_stream.py", line 101, in retried_func raise requests.exceptions.HTTPError requests.exceptions.HTTPError
2100
from search-tweets-python.
A quick thing that might work is to use https://github.com/tomasbasham/ratelimit
like this: https://github.com/igorbrigadir/search-tweets-python/blob/rate-limits/searchtweets/result_stream.py#L111-L113
(but numbers of calls are different for products so they should be in a config file somewhere)
from search-tweets-python.
FWIW, these updates were recently made:
I made some updates to the HTTP error handling. Previously, there was a general mechanism to retry 3 times for every error. This retry mechanism had a backoff design, but there was not a long enough delay duration to recover from a rate limit error. It also treated all errors the same, retrying three times even if your credentials were wrong.
So, this new update does the following:
With rate limit errors, it backs off exponentially across a fifteen-minute period and should recover from such errors and continue on.
Retries with 5xx server-side errors, 30 seconds between retries.
All other errors (4xx) are treated as "one and done, no use in retrying..." errors.
from search-tweets-python.
Related Issues (20)
- No output file when using write_result_stream HOT 4
- Changing the number of results returned per API (v2) call/request HOT 1
- results_per_call and granularity argument for gen_request_parameter() not working in v1.1.1 HOT 4
- Make granularity as an optional parameter HOT 1
- Docs error HOT 1
- Warnings about urllib3 and chardet
- Requests 104 Error on tweets search in api 2.0 HOT 2
- Docs error in README.rst
- Problem in geo parsing in v2 API HOT 3
- Cannot import name 'gen_rule_payload' from 'searchtweets' HOT 1
- Cannot access tweets through a ResultStream from behind a proxy HOT 2
- Parameter `sort_order` is missing in `gen_request_parameters()` (v2)
- start-time end-time arguments having no effect HOT 2
- Can you give me a complete example code?
- It collects different number of tweets, while running exactly the same query. HOT 1
- How to collect tweets based on a list of IDs? HOT 2
- handle specifiable limits (twitter dev account got suspended) HOT 2
- I should be able to search for my own tweets, even if my account is private
- json.decoder.JSONDecodeError on Python 3.6 HOT 1
- Is there a search term operator for finding that have a community note attached?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from search-tweets-python.