From f6d458e7587069852af1cb05aba4cfc5e382df4b Mon Sep 17 00:00:00 2001 From: Mike Helmick Date: Wed, 25 Sep 2013 12:58:40 -0400 Subject: [PATCH] Fixes #230 --- twython/streaming/api.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/twython/streaming/api.py b/twython/streaming/api.py index ef8924a..a27e6cd 100644 --- a/twython/streaming/api.py +++ b/twython/streaming/api.py @@ -21,7 +21,7 @@ import time class TwythonStreamer(object): def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret, timeout=300, retry_count=None, retry_in=10, client_args=None, - handlers=None): + handlers=None, chunk_size=1): """Streaming class for a friendly streaming user experience Authentication IS required to use the Twitter Streaming API @@ -42,6 +42,9 @@ class TwythonStreamer(object): [ex. headers, proxies, verify(SSL verification)] :param handlers: (optional) Array of message types for which corresponding handlers will be called + + :param chunk_size: (optional) Define the buffer size before data is + actually returned from the Streaming API. Default: 1 """ self.auth = OAuth1(app_key, app_secret, @@ -124,7 +127,7 @@ class TwythonStreamer(object): while self.connected: response = _send(retry_counter) - for line in response.iter_lines(): + for line in response.iter_lines(self.chunk_size): if not self.connected: break if line: