private void disposeConsoleProcess() throws InterruptedException {
    myProcessHandler.destroyProcess();

    waitFor(myProcessHandler);

    if (!myProcessHandler.isProcessTerminated()) {
      if (!waitFor(myProcessHandler)) {
        if (!myProcessHandler.isProcessTerminated()) {
          throw new RuntimeException("Cannot stop console process");
        }
      }
    }
    myProcessHandler = null;
  }
  public void initAndRun(final String... statements2execute) throws ExecutionException {
    super.initAndRun();

    if (handshake()) {

      ApplicationManager.getApplication()
          .invokeLater(
              new Runnable() {

                @Override
                public void run() {
                  // Propagate console communication to language console
                  final PythonConsoleView consoleView = getConsoleView();

                  consoleView.setConsoleCommunication(myPydevConsoleCommunication);
                  consoleView.setSdk(mySdk);
                  consoleView.setExecutionHandler(myConsoleExecuteActionHandler);
                  myProcessHandler.addProcessListener(
                      new ProcessAdapter() {
                        @Override
                        public void onTextAvailable(ProcessEvent event, Key outputType) {
                          consoleView.print(event.getText(), outputType);
                        }
                      });

                  enableConsoleExecuteAction();

                  for (String statement : statements2execute) {
                    consoleView.executeStatement(statement + "\n", ProcessOutputTypes.SYSTEM);
                  }

                  fireConsoleInitializedEvent(consoleView);
                }
              });
    } else {
      getConsoleView().print("Couldn't connect to console process.", ProcessOutputTypes.STDERR);
      myProcessHandler.destroyProcess();
      finishConsole();
    }
  }