Skip to content

Commit 700fbef

Browse files
committed
Fix broken unbuffered streaming with Py3
Signed-off-by: Joffrey F <[email protected]>
1 parent f238fe5 commit 700fbef

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

docker/transport/unixconn.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
class UnixHTTPResponse(httplib.HTTPResponse, object):
2222
def __init__(self, sock, *args, **kwargs):
2323
disable_buffering = kwargs.pop('disable_buffering', False)
24+
if six.PY2:
25+
# FIXME: We may need to disable buffering on Py3 as well,
26+
# but there's no clear way to do it at the moment. See:
27+
# https://github.com/docker/docker-py/issues/1799
28+
kwargs['buffering'] = not disable_buffering
2429
super(UnixHTTPResponse, self).__init__(sock, *args, **kwargs)
25-
if disable_buffering is True:
26-
# We must first create a new pointer then close the old one
27-
# to avoid closing the underlying socket.
28-
new_fp = sock.makefile('rb', 0)
29-
self.fp.close()
30-
self.fp = new_fp
3130

3231

3332
class UnixHTTPConnection(httplib.HTTPConnection, object):

0 commit comments

Comments
 (0)