Skip to content

Commit 02787ce

Browse files
author
Aaron Gonzales
authored
Merge pull request #8 from tw-ddis/session_counter
added a API call counter for all result stream objects within a program.
2 parents 117a115 + d51256b commit 02787ce

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

twittersearch/result_stream.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ class ResultStream:
144144
>>> results = list(rs.stream())
145145
146146
"""
147+
# leaving this here to have an API call counter for ALL objects in your
148+
# session, helping with usage of the convenience functions in the library.
149+
session_request_counter = 0
147150

148151
def __init__(self, endpoint, rule_payload, username=None, password=None,
149152
bearer_token=None, max_results=1000,
@@ -241,6 +244,7 @@ def execute_request(self):
241244
url=self.endpoint,
242245
rule_payload=self.rule_payload)
243246
self.n_requests += 1
247+
ResultStream.session_request_counter += 1
244248
resp = json.loads(resp.content.decode(resp.encoding))
245249
self.next_token = resp.get("next", None)
246250
self.current_tweets = resp["results"]

0 commit comments

Comments
 (0)