From: Ed Page Date: Sat, 25 Apr 2009 03:01:42 +0000 (-0500) Subject: Minor cleaning up of the new read code X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=e558d14d1c3f82647a67c399805420d5e55fd1ca;p=doneit Minor cleaning up of the new read code --- diff --git a/src/rtm_api.py b/src/rtm_api.py index b748b38..a184328 100644 --- a/src/rtm_api.py +++ b/src/rtm_api.py @@ -103,16 +103,17 @@ class RTMapi(object): actuallyRead = 0 chunks = [] + chunk = connection.read() - while 0 < timeout: - actuallyRead += len(chunk) - if actuallyRead == specifiedLength: - break - chunks.append(chunk) + actuallyRead += len(chunk) + chunks.append(chunk) + while 0 < timeout and actuallyRead < specifiedLength: time.sleep(1) timeout -= 1 chunk = connection.read() - chunks.append(chunk) + actuallyRead += len(chunk) + chunks.append(chunk) + json = "".join(chunks) if "Content-Length" in connection.info(): @@ -131,13 +132,15 @@ class RTMapi(object): # to grab data. chunks = [] + chunk = connection.read() + chunks.append(chunk) while chunk and 0 < timeout: - chunks.append(chunk) time.sleep(1) timeout -= 1 chunk = connection.read() - chunks.append(chunk) + chunks.append(chunk) + json = "".join(chunks) if "Content-Length" in connection.info():