Merge pull request #1344 from psviderski/fix/logs_performance

Dramatically increase get logs performance
This commit is contained in:
Joffrey F 2017-02-06 17:01:58 -08:00 committed by GitHub
commit 96a9eaced6
1 changed files with 4 additions and 2 deletions

View File

@ -302,11 +302,13 @@ class APIClient(
"""A generator of multiplexed data blocks read from a buffered
response."""
buf = self._result(response, binary=True)
buf_length = len(buf)
walker = 0
while True:
if len(buf[walker:]) < 8:
if buf_length - walker < STREAM_HEADER_SIZE_BYTES:
break
_, length = struct.unpack_from('>BxxxL', buf[walker:])
header = buf[walker:walker + STREAM_HEADER_SIZE_BYTES]
_, length = struct.unpack_from('>BxxxL', header)
start = walker + STREAM_HEADER_SIZE_BYTES
end = start + length
walker = end