Commit da7a5da5 authored by AlanBell's avatar AlanBell
Browse files

_read_loop really didn't seem right, but somehow kinda worked. It now works...

_read_loop really didn't seem right, but somehow kinda worked. It now works when pointed at user streams too.
parent fcaff746
......@@ -136,26 +136,20 @@ class Stream(object):
raise exception
def _read_loop(self, resp):
data = ''
while self.running:
while self.running:
if resp.isclosed():
break
# read length
length = ''
data = ''
while True:
c = resp.read(1)
if c == '\n':
break
length += c
length = length.strip()
if length.isdigit():
length = int(length)
else:
continue
data += c
data = data.strip()
# read data and pass into listener
data = resp.read(length)
if self.listener.on_data(data) is False:
self.running = False
......
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