Skip to content

Commit 537b468

Browse files
committed
Fix attaching with UNIX sockets
Signed-off-by: Ben Firshman <[email protected]>
1 parent 721edfd commit 537b468

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docker/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,16 @@ def _get_raw_response_socket(self, response):
262262
sock = response.raw._fp.fp.raw._sock
263263
else:
264264
sock = response.raw._fp.fp._sock
265-
sock._response = response
265+
try:
266+
# Keep a reference to the response to stop it being garbage
267+
# collected. If the response is garbage collected, it will close
268+
# TLS sockets.
269+
sock._response = response
270+
except AttributeError:
271+
# UNIX sockets can't have attributes set on them, but that's fine
272+
# because we won't be doing TLS over them
273+
pass
274+
266275
return sock
267276

268277
def _stream_helper(self, response):

0 commit comments

Comments
 (0)