summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2017-11-08 16:01:19 -0800
committerJoffrey F <f.joffrey@gmail.com>2017-11-08 16:29:56 -0800
commit700fbef42b0a269204bfbe03c9404c059ec95d98 (patch)
tree840a30428b29edb97e9b57e9aee548377dff0fdd
parentf238fe5554cca48bb9bb366a07bd219c090e445b (diff)
downloaddocker-py-700fbef42b0a269204bfbe03c9404c059ec95d98.tar.gz
Fix broken unbuffered streaming with Py3
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/transport/unixconn.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/docker/transport/unixconn.py b/docker/transport/unixconn.py
index 7cb8771..cc35d00 100644
--- a/docker/transport/unixconn.py
+++ b/docker/transport/unixconn.py
@@ -21,13 +21,12 @@ RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer
class UnixHTTPResponse(httplib.HTTPResponse, object):
def __init__(self, sock, *args, **kwargs):
disable_buffering = kwargs.pop('disable_buffering', False)
+ if six.PY2:
+ # FIXME: We may need to disable buffering on Py3 as well,
+ # but there's no clear way to do it at the moment. See:
+ # https://github.com/docker/docker-py/issues/1799
+ kwargs['buffering'] = not disable_buffering
super(UnixHTTPResponse, self).__init__(sock, *args, **kwargs)
- if disable_buffering is True:
- # We must first create a new pointer then close the old one
- # to avoid closing the underlying socket.
- new_fp = sock.makefile('rb', 0)
- self.fp.close()
- self.fp = new_fp
class UnixHTTPConnection(httplib.HTTPConnection, object):