Commit 5d275bc7 authored by Steve Jones's avatar Steve Jones
Browse files

Update to streaming read loop to use delimited stream mode.

1) read newlines until a digit appears
2) read rest of digits until another new line appears
3) read next status object
4) repeat

-improved speed over trunk version
-simplify loop logic
-added condition for "self.running and not resp.isclosed()" during each read-loop stage 
parent a5161337
......@@ -147,18 +147,14 @@ class Stream(object):
# Note: keep-alive newlines might be inserted before each length value.
# read until we get a digit...
c = ''
while c not in digits:
c = '\n'
while c == '\n' and self.running and not resp.isclosed():
c =
delimited_string = c
# read rest of delimiter length..
while 1:
d =
if d in digits:
delimited_string += d
while d != '\n' and self.running and not resp.isclosed():
delimited_string +=
# read the next twitter status object
if delimited_string.isdigit():
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment