Skip to content

Commit abd4611

Browse files
authored
Merge pull request #1081 from tescalada/master
1059-Fixing a bug with multiple json objects
2 parents 0acdd19 + f8b843b commit abd4611

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

docker/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,16 @@ def _stream_helper(self, response, decode=False):
255255
if decode:
256256
if six.PY3:
257257
data = data.decode('utf-8')
258-
data = json.loads(data)
259-
yield data
258+
# remove the trailing newline
259+
data = data.strip()
260+
# split the data at any newlines
261+
data_list = data.split("\r\n")
262+
# load and yield each line seperately
263+
for data in data_list:
264+
data = json.loads(data)
265+
yield data
266+
else:
267+
yield data
260268
else:
261269
# Response isn't chunked, meaning we probably
262270
# encountered an error immediately

0 commit comments

Comments
 (0)