from idlelib import RemoteDebugger
from idlelib import macosxSupport
+HOST = '127.0.0.1' # python execution server on localhost loopback
+PORT = 0 # someday pass in host, port for remote debug capability
from signal import SIGTERM
self.save_warnings_filters = None
- self.subprocess_arglist = self.build_subprocess_arglist()
+ self.subprocess_arglist = None
+ if self.subprocess_arglist == None:
+ self.subprocess_arglist = self.build_subprocess_arglist()
args = self.subprocess_arglist
self.rpcpid = os.spawnv(os.P_NOWAIT, sys.executable, args)
+ assert (self.port!=0), (
+ "Socket should have been assigned a port number.")
w = ['-W' + s for s in sys.warnoptions]
# Maybe IDLE is installed and is being accessed via sys.path,
# or maybe it's not installed and the idle.py script is being
return [decorated_exec] + w + ["-c", command, str(self.port)]
- # spawning first avoids passing a listening socket to the subprocess
- #time.sleep(20) # test to simulate GUI not accepting connection
- addr = (LOCALHOST, self.port)
- # Idle starts listening for connection on localhost
+ addr = (HOST, self.port)
+ # GUI makes several attempts to acquire socket, listens for connection
+ # if PORT was 0, system will assign an 'ephemeral' port. Find it out:
+ self.port = self.rpcclt.listening_sock.getsockname()
+ # if PORT was not 0, probably working with a remote execution server
+ # To allow reconnection within the 2MSL wait (cf. Stevens TCP
+ # V1, 18.6), set SO_REUSEADDR. Note that this can be problematic
+ # on Windows since the implementation allows two active sockets on
+ socket.SO_REUSEADDR, 1)
+ #time.sleep(20) # test to simulate GUI not accepting connection
# Accept the connection from the Python execution server
- "IDLE can't bind TCP/IP port 8833, which is necessary to "
- "communicate with its Python execution server. Either "
- "no networking is installed on this computer or another "
- "process (another IDLE?) is using the port. Run IDLE with the -n "
- "command line switch to start without a subprocess and refer to "
- "Help/IDLE Help 'Running without a subprocess' for further "
+ "IDLE can't bind to a TCP/IP port, which is necessary to "
+ "communicate with its Python execution server. This might be "
+ "because no networking is installed on this computer. "
+ "Run IDLE with the -n command line switch to start without a "
+ "subprocess and refer to Help/IDLE Help 'Running without a "
+ "subprocess' for further details.",
global flist, root, use_subprocess
edit_start = idleConf.GetOption('main', 'General',
enable_edit = enable_edit or edit_start
- enable_shell = enable_shell or not edit_start
# start editor and/or shell windows:
root = Tk(className="Idle")