diff options
author | Aanand Prasad <aanand.prasad@gmail.com> | 2016-07-13 16:53:41 -0400 |
---|---|---|
committer | Aanand Prasad <aanand.prasad@gmail.com> | 2016-07-13 17:08:17 -0400 |
commit | 456bfa1c1d2bbca68eb91343d210f55f645c5a33 (patch) | |
tree | a591a43f554fbf479f75f6b0d990fc7dc5e8c034 | |
parent | 472a7ffce8032a92dbcc264b9178a3e92695f8ae (diff) | |
download | docker-py-456bfa1c1d2bbca68eb91343d210f55f645c5a33.tar.gz |
Reorder socket.py methods
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
-rw-r--r-- | docker/utils/socket.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/docker/utils/socket.py b/docker/utils/socket.py index 47b2320..0174d5f 100644 --- a/docker/utils/socket.py +++ b/docker/utils/socket.py @@ -28,6 +28,19 @@ def read_socket(socket, n=4096): raise +def read_data(socket, n): + """ + Reads exactly n bytes from socket + """ + data = six.binary_type() + while len(data) < n: + next_data = read_socket(socket, n - len(data)) + if not next_data: + raise SocketError("Unexpected EOF") + data += next_data + return data + + def next_packet_size(socket): """ Returns the size of the next frame of data waiting to be read from socket, @@ -44,19 +57,6 @@ def next_packet_size(socket): return actual -def read_data(socket, n): - """ - Reads exactly n bytes from socket - """ - data = six.binary_type() - while len(data) < n: - next_data = read_socket(socket, n - len(data)) - if not next_data: - raise SocketError("Unexpected EOF") - data += next_data - return data - - def read_iter(socket): """ Returns a generator of frames read from socket |