We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bc0a5fb commit 3002298Copy full SHA for 3002298
1 file changed
docker/utils/socket.py
@@ -18,6 +18,11 @@ class SocketError(Exception):
18
pass
19
20
21
+# NpipeSockets have their own error types
22
+# pywintypes.error: (109, 'ReadFile', 'The pipe has been ended.')
23
+NPIPE_ENDED = 109
24
+
25
26
def read(socket, n=4096):
27
"""
28
Reads at most n bytes from socket
@@ -37,6 +42,15 @@ def read(socket, n=4096):
37
42
except OSError as e:
38
43
if e.errno not in recoverable_errors:
39
44
raise
45
+ except Exception as e:
46
+ is_pipe_ended = (isinstance(socket, NpipeSocket) and
47
+ len(e.args) > 0 and
48
+ e.args[0] == NPIPE_ENDED)
49
+ if is_pipe_ended:
50
+ # npipes don't support duplex sockets, so we interpret
51
+ # a PIPE_ENDED error as a close operation (0-length read).
52
+ return 0
53
+ raise
40
54
41
55
56
def read_exactly(socket, n):
0 commit comments