diff -u --exclude=tags --exclude='*.pyc' STUFF/patched/PyShell.py ./PyShell.py --- STUFF/patched/PyShell.py 2005-05-13 13:17:20.406910929 -0400 +++ ./PyShell.py 2005-05-13 13:55:03.295289485 -0400 @@ -339,9 +339,8 @@ InteractiveInterpreter.__init__(self, locals=locals) self.save_warnings_filters = None self.restarting = False - self.subprocess_arglist = self.build_subprocess_arglist() - port = 8833 + default_port = 8833 rpcclt = None rpcpid = None @@ -368,13 +367,10 @@ return [decorated_exec] + w + ["-c", command, str(self.port)] def start_subprocess(self): - # spawning first avoids passing a listening socket to the subprocess - self.spawn_subprocess() - #time.sleep(20) # test to simulate GUI not accepting connection - addr = (LOCALHOST, self.port) - # Idle starts listening for connection on localhost - for i in range(3): - time.sleep(i) + for i in range(10): + self.port = self.default_port+i + self.subprocess_arglist = self.build_subprocess_arglist() + addr = (LOCALHOST, self.port) try: self.rpcclt = MyRPCClient(addr) break @@ -383,6 +379,9 @@ else: self.display_port_binding_error() return None + # Start subprocess after binding port to avoid race condition of + # starting subprocess that will attach to another guis port. + self.spawn_subprocess() # Accept the connection from the Python execution server self.rpcclt.listening_sock.settimeout(10) try: @@ -729,13 +728,13 @@ def display_port_binding_error(self): tkMessageBox.showerror( "Port Binding Error", - "IDLE can't bind TCP/IP port 8833, which is necessary to " + "IDLE can't bind any TCP/IP port in range %d-%d, 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 " + "no networking is installed on this computer or other " + "processes (other IDLEs?) are using all these ports. 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.", + "details."%(self.default_port,self.port), master=self.tkconsole.text) def display_no_subprocess_error(self):