[Pydev-cvs] org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole PydevXmlRpcClient
Brought to you by:
fabioz
Update of /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8125/src_console/org/python/pydev/debug/newconsole Modified Files: PydevXmlRpcClient.java PydevConsoleCommunication.java PydevConsoleConstants.java PydevConsolePreferencesInitializer.java Log Message: Maximum number of attempts to connect to the shell initially raised (and can now be configured). Index: PydevConsoleConstants.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleConstants.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PydevConsoleConstants.java 7 Apr 2008 01:57:14 -0000 1.6 --- PydevConsoleConstants.java 15 Jun 2008 19:01:31 -0000 1.7 *************** *** 42,45 **** --- 42,48 ---- public static final String INITIAL_INTERPRETER_CMDS = "INITIAL_INTERPRETER_CMDS"; public static final String DEFAULT_INITIAL_INTERPRETER_CMDS = "import sys; print '%s %s' % (sys.executable or sys.platform, sys.version)\n"; + + public static final String INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS = "INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS"; + public static final int DEFAULT_INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS = 20; } Index: PydevXmlRpcClient.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevXmlRpcClient.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PydevXmlRpcClient.java 7 Apr 2008 01:57:14 -0000 1.2 --- PydevXmlRpcClient.java 15 Jun 2008 19:01:31 -0000 1.3 *************** *** 69,73 **** final Object[] result = new Object[]{null}; ! //make ana async call so that we can keep track of not actually having an answer. this.impl.executeAsync(command, args, new AsyncCallback(){ --- 69,73 ---- final Object[] result = new Object[]{null}; ! //make an async call so that we can keep track of not actually having an answer. this.impl.executeAsync(command, args, new AsyncCallback(){ Index: PydevConsolePreferencesInitializer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsolePreferencesInitializer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PydevConsolePreferencesInitializer.java 4 Apr 2008 02:54:42 -0000 1.3 --- PydevConsolePreferencesInitializer.java 15 Jun 2008 19:01:31 -0000 1.4 *************** *** 37,40 **** --- 37,43 ---- node.put(PydevConsoleConstants.INTERACTIVE_CONSOLE_VM_ARGS, PydevConsoleConstants.DEFAULT_INTERACTIVE_CONSOLE_VM_ARGS); node.put(PydevConsoleConstants.INITIAL_INTERPRETER_CMDS, PydevConsoleConstants.DEFAULT_INITIAL_INTERPRETER_CMDS); + + node.putInt(PydevConsoleConstants.INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS, + PydevConsoleConstants.DEFAULT_INTERACTIVE_CONSOLE_MAXIMUM_CONNECTION_ATTEMPTS); } Index: PydevConsoleCommunication.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleCommunication.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PydevConsoleCommunication.java 12 Apr 2008 15:39:58 -0000 1.9 --- PydevConsoleCommunication.java 15 Jun 2008 19:01:31 -0000 1.10 *************** *** 12,19 **** --- 12,24 ---- import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.webserver.WebServer; + import org.eclipse.core.runtime.IProgressMonitor; + import org.eclipse.core.runtime.IStatus; + import org.eclipse.core.runtime.Status; + import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.python.pydev.core.ICompletionState; import org.python.pydev.core.IToken; import org.python.pydev.core.Tuple; + import org.python.pydev.debug.newconsole.prefs.InteractiveConsolePrefs; import org.python.pydev.dltk.console.IScriptConsoleCommunication; import org.python.pydev.dltk.console.InterpreterResponse; *************** *** 91,96 **** public void close() throws Exception { if(this.client != null){ ! this.client.execute("close", new Object[0]); ! this.client = null; } --- 96,112 ---- public void close() throws Exception { if(this.client != null){ ! new Job("Close console communication"){ ! ! @Override ! protected IStatus run(IProgressMonitor monitor) { ! try { ! PydevConsoleCommunication.this.client.execute("close", new Object[0]); ! } catch (Exception e) { ! //Ok, we can ignore this one on close. ! } ! PydevConsoleCommunication.this.client = null; ! return Status.OK_STATUS; ! } ! }.schedule(); //finish it } *************** *** 178,183 **** }else{ //create a thread that'll keep locked until an answer is received from the server. ! Thread thread = new Thread(){ ! /** * Executes the needed command --- 194,199 ---- }else{ //create a thread that'll keep locked until an answer is received from the server. ! Job job = new Job("Pydev Console Communication"){ ! /** * Executes the needed command *************** *** 215,219 **** @Override ! public void run() { boolean needInput = false; try{ --- 231,235 ---- @Override ! protected IStatus run(IProgressMonitor monitor) { boolean needInput = false; try{ *************** *** 222,230 **** ! //the 1st time we'll do a connection attempt, we can try up to 5 times (until the 1st time the connection ! //is accepted) int commAttempts = 0; while(true){ executed = exec(); --- 238,251 ---- ! //the 1st time we'll do a connection attempt, we can try to connect n times (until the 1st time the connection ! //is accepted) -- that's mostly because the server may take a while to get started. int commAttempts = 0; + int maximumAttempts = InteractiveConsolePrefs.getMaximumAttempts(); + //System.out.println(maximumAttempts); while(true){ + if(monitor.isCanceled()){ + return Status.CANCEL_STATUS; + } executed = exec(); *************** *** 234,238 **** break; }else{ ! if(commAttempts < 5){ commAttempts += 1; continue; --- 255,259 ---- break; }else{ ! if(commAttempts < maximumAttempts){ commAttempts += 1; continue; *************** *** 246,250 **** } ! //unreachable code!! //throw new RuntimeException("Can never get here!"); } --- 267,271 ---- } ! //unreachable code!! -- commented because eclipse will complain about it //throw new RuntimeException("Can never get here!"); } *************** *** 265,271 **** false, needInput); } } }; ! thread.start(); } --- 286,295 ---- false, needInput); } + return Status.OK_STATUS; } }; ! ! job.schedule(); ! } *************** *** 274,278 **** synchronized(lock2){ try { ! lock2.wait(10); } catch (InterruptedException e) { PydevPlugin.log(e); --- 298,302 ---- synchronized(lock2){ try { ! lock2.wait(20); } catch (InterruptedException e) { PydevPlugin.log(e); |