Issue 13300: IDLE 3.3 Restart Shell command fails (original) (raw)
Currently in the default (pre-3.3) branch, IDLE fails if its Restart Shell command is attempted:
Exception in Tkinter callback Traceback (most recent call last): File "Lib/tkinter/init.py", line 1397, in call return self.func(*args) File "Lib/idlelib/PyShell.py", line 1180, in restart_shell self.interp.restart_subprocess() File "Lib/idlelib/PyShell.py", line 429, in restart_subprocess self.rpcclt.accept() File "Lib/idlelib/rpc.py", line 525, in accept working_sock, address = self.listening_sock.accept() File "Lib/socket.py", line 134, in accept fd, addr = self._accept() OSError: [Errno 9] Bad file descriptor IDLE Subprocess: socket error: Connection refused, retrying.... IDLE Subprocess: socket error: Connection refused, retrying....
Warning (from warnings module): File "Lib/idlelib/run.py", line 127 socket_error = err ResourceWarning: unclosed <socket.socket object, fd=3, family=2, type=1, proto=0> IDLE Subprocess: socket error: Connection refused, retrying....
The culprit is recent changeset 3a5a0943b201 which attempted to prevent some debug ResourceWarnings during IDLE shutdown. Adding the close override to the RPCClient class causes the listening socket to be closed when the shell is restarted but then a new listening socket is not opened. The listening socket should only be closed when IDLE terminates, not when the subprocess is restarted.