File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ class SocketError(Exception):
18
18
pass
19
19
20
20
21
+ # NpipeSockets have their own error types
22
+ # pywintypes.error: (109, 'ReadFile', 'The pipe has been ended.')
23
+ NPIPE_ENDED = 109
24
+
25
+
21
26
def read (socket , n = 4096 ):
22
27
"""
23
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
42
56
def read_exactly (socket , n ):
You can’t perform that action at this time.
0 commit comments