Skip to content

Commit ddaf616

Browse files
committed
Expect OSError during socket shutdown, can happen if other end has already closed the socket
1 parent 3ec66ea commit ddaf616

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

proxy/core/connection/pool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ def _remove(self, fileno: int) -> None:
174174
"""Remove a connection by descriptor from the internal data structure."""
175175
conn = self.connections[fileno]
176176
logger.debug('Removing conn#{0} from pool'.format(id(conn)))
177-
conn.connection.shutdown(socket.SHUT_WR)
177+
try:
178+
conn.connection.shutdown(socket.SHUT_WR)
179+
except OSError:
180+
pass
178181
conn.close()
179182
self.pools[conn.addr].remove(conn)
180183
del self.connections[fileno]

proxy/http/websocket/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,8 @@ def run(self) -> None:
115115
finally:
116116
if not self.closed:
117117
self.selector.unregister(self.sock)
118-
self.sock.shutdown(socket.SHUT_WR)
118+
try:
119+
self.sock.shutdown(socket.SHUT_WR)
120+
except OSError:
121+
pass
119122
self.sock.close()

0 commit comments

Comments
 (0)