src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py

branch
eric7
changeset 10954
c3d109783fbd
parent 10953
42166c630d9b
child 10956
1c22b555df34
equal deleted inserted replaced
10953:42166c630d9b 10954:c3d109783fbd
5 5
6 """ 6 """
7 Module implementing the debugger request handler of the eric-ide server. 7 Module implementing the debugger request handler of the eric-ide server.
8 """ 8 """
9 9
10 import contextlib
10 import json 11 import json
11 import os 12 import os
12 import selectors 13 import selectors
13 import socket 14 import socket
14 import subprocess 15 import subprocess
171 @param sock reference to the disconnected socket 172 @param sock reference to the disconnected socket
172 @type socket.socket 173 @type socket.socket
173 """ 174 """
174 self._server.getSelector().unregister(sock) 175 self._server.getSelector().unregister(sock)
175 176
176 address = sock.getpeername() 177 with contextlib.suppress(OSError):
177 print( # noqa: M801 178 address = sock.getpeername()
178 f"'Debug Client' connection from {address[0]}, port {address[1]} closed." 179 print( # noqa: M801
179 ) 180 f"'Debug Client' connection from {address[0]}, port {address[1]}"
181 f" closed."
182 )
180 183
181 for debuggerId in list(self.__connections): 184 for debuggerId in list(self.__connections):
182 if self.__connections[debuggerId] is sock: 185 if self.__connections[debuggerId] is sock:
183 del self.__connections[debuggerId] 186 del self.__connections[debuggerId]
184 self._server.sendJson( 187 self._server.sendJson(
238 @param debuggerId ID of the debugger the socket belongs to 241 @param debuggerId ID of the debugger the socket belongs to
239 @type str 242 @type str
240 @param sock reference to the socket 243 @param sock reference to the socket
241 @type socket.socket 244 @type socket.socket
242 """ 245 """
243 self._server.getSelector().unregister(sock) 246 with contextlib.suppress(KeyError):
247 # Socket might have been unregister automatically (e.g. due to a crash of
248 # the script being debugged).
249 self._server.getSelector().unregister(sock)
244 sock.shutdown(socket.SHUT_RDWR) 250 sock.shutdown(socket.SHUT_RDWR)
245 sock.close() 251 sock.close()
246 252
247 if debuggerId: 253 if debuggerId:
248 self._server.sendJson( 254 self._server.sendJson(

eric ide

mercurial