diff -r 42166c630d9b -r c3d109783fbd src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py --- a/src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py Sat Oct 05 14:14:59 2024 +0200 +++ b/src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py Sat Oct 05 17:54:28 2024 +0200 @@ -7,6 +7,7 @@ Module implementing the debugger request handler of the eric-ide server. """ +import contextlib import json import os import selectors @@ -173,10 +174,12 @@ """ self._server.getSelector().unregister(sock) - address = sock.getpeername() - print( # noqa: M801 - f"'Debug Client' connection from {address[0]}, port {address[1]} closed." - ) + with contextlib.suppress(OSError): + address = sock.getpeername() + print( # noqa: M801 + f"'Debug Client' connection from {address[0]}, port {address[1]}" + f" closed." + ) for debuggerId in list(self.__connections): if self.__connections[debuggerId] is sock: @@ -240,7 +243,10 @@ @param sock reference to the socket @type socket.socket """ - self._server.getSelector().unregister(sock) + with contextlib.suppress(KeyError): + # Socket might have been unregister automatically (e.g. due to a crash of + # the script being debugged). + self._server.getSelector().unregister(sock) sock.shutdown(socket.SHUT_RDWR) sock.close()