diff options
author | Joffrey F <joffrey@docker.com> | 2017-06-23 17:37:25 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2017-08-16 15:07:24 -0700 |
commit | 942e778f302199ff6ec677860aa28d07f69e11da (patch) | |
tree | ae9234b4d93bf26c2ff6bd5bd239b11667b4fde8 /docker/utils/socket.py | |
parent | e9fab1432b974ceaa888b371e382dfcf2f6556e4 (diff) | |
download | docker-py-fix_frames_iter.tar.gz |
Fix frames_iter buffering/streaming logicfix_frames_iter
Use single method to process logs/attach output
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/utils/socket.py')
-rw-r--r-- | docker/utils/socket.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/docker/utils/socket.py b/docker/utils/socket.py index 4080f25..7542bc3 100644 --- a/docker/utils/socket.py +++ b/docker/utils/socket.py @@ -5,6 +5,8 @@ import struct import six +from ..constants import STREAM_HEADER_SIZE_BYTES + try: from ..transport import NpipeSocket except ImportError: @@ -57,7 +59,7 @@ def next_frame_size(socket): https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#/attach-to-a-container """ try: - data = read_exactly(socket, 8) + data = read_exactly(socket, STREAM_HEADER_SIZE_BYTES) except SocketError: return 0 @@ -75,5 +77,10 @@ def frames_iter(socket): break while n > 0: result = read(socket, n) - n -= len(result) + data_length = len(result) + if data_length == 0: + # We have reached EOF + return + + n -= data_length yield result |