}
int acceptTimeout = PydevPrefs.getPreferences().getInt(PydevEditorPrefs.CONNECT_TIMEOUT);
PyDebugTargetConsole pyDebugTargetConsole = null;
IProcess eclipseProcess = interpreter.getLaunch().getProcesses()[0];
RemoteDebuggerConsole debugger = new RemoteDebuggerConsole();
ListenConnector connector = new ListenConnector(acceptTimeout);
debugger.startConnect(connector);
pyDebugTargetConsole = new PyDebugTargetConsole(consoleCommunication, interpreter.getLaunch(),
eclipseProcess, debugger);
Socket socket = null;
try {
consoleCommunication.connectToDebugger(connector.getLocalPort());
socket = debugger.waitForConnect(monitor, process, eclipseProcess);
if (socket == null) {
throw new UserCanceledException("Cancelled");
}
} catch (Exception ex) {
try {
if (ex instanceof UserCanceledException) {
//Only close the console communication if the user actually cancelled (otherwise the user will expect it to still be working).
consoleCommunication.close();
debugger.dispose(); //Can't terminate the process either!
} else {
//But we still want to dispose of the connector.
debugger.disposeConnector();
}
} catch (Exception e) {
// Don't hide important information from user
Log.log(e);
}