diff options
author | Joffrey F <f.joffrey@gmail.com> | 2016-08-23 15:10:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-23 15:10:56 -0700 |
commit | abd461150a7b66314ab88c173475680fee2ec7eb (patch) | |
tree | 2ad455759b4732f97e7575300c7ea95d1fd24c06 | |
parent | 0acdd19665266c7b5c7e8e6d39e69781b4ab30a3 (diff) | |
parent | f8b843b127a99dc329b9da7da4bedc050be36ebf (diff) | |
download | docker-py-abd461150a7b66314ab88c173475680fee2ec7eb.tar.gz |
Merge pull request #1081 from tescalada/master
1059-Fixing a bug with multiple json objects
-rw-r--r-- | docker/client.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/docker/client.py b/docker/client.py index 6c1e189..7586753 100644 --- a/docker/client.py +++ b/docker/client.py @@ -255,8 +255,16 @@ class Client( if decode: if six.PY3: data = data.decode('utf-8') - data = json.loads(data) - yield data + # remove the trailing newline + data = data.strip() + # split the data at any newlines + data_list = data.split("\r\n") + # load and yield each line seperately + for data in data_list: + data = json.loads(data) + yield data + else: + yield data else: # Response isn't chunked, meaning we probably # encountered an error immediately |