private void initAndRun(@NotNull Sdk sdk) throws ExecutionException {
    // Create Server process
    ConsoleProcessCreationResult processCreationResult;
    boolean isUseTargetsAPI = Registry.is("python.use.targets.api");
    if (isUseTargetsAPI) {
      processCreationResult = createProcessUsingTargetsAPI(sdk);
    }
    else if (PyRunnerUtil.isTargetBased(sdk)) {
      throw new ExecutionException(PySdkBundle.message("python.sdk.please.reconfigure.interpreter"));
    }
    else {
      processCreationResult = createProcess(sdk);
    }
    TargetEnvironment targetEnvironment = processCreationResult.getTargetEnvironment();
    UIUtil.invokeAndWaitIfNeeded(() -> {
      // Init console view
      myConsoleView = createConsoleView(sdk);
      myConsoleView.setRunner(this);
      myConsoleView.setBorder(new SideBorder(JBColor.border(), SideBorder.LEFT));
      myPydevConsoleCommunication.setConsoleView(myConsoleView);
      myProcessHandler = processCreationResult.createPythonConsoleProcessHandler(myConsoleView);

      myConsoleExecuteActionHandler = createExecuteActionHandler();

      ProcessTerminatedListener.attach(myProcessHandler);

      PythonConsoleView consoleView = myConsoleView;
      myProcessHandler.addProcessListener(new ProcessAdapter() {
        @Override
        public void processTerminated(@NotNull ProcessEvent event) {
          consoleView.setEditable(false);
          // PY-53068: When we send to python side command `exit` we don't get notifyFinished,
          // so we should clear Console Command Queue
          consoleView.restoreQueueWindow(true);
        }
      });

      // Attach to process
      if (targetEnvironment != null) {
        myConsoleView.setTargetEnvironment(targetEnvironment);
      }
      myConsoleView.attachToProcess(myProcessHandler);
      createContentDescriptorAndActions();

      // Run
      myProcessHandler.startNotify();
    });
  }
private void initAndRun(@NotNull Sdk sdk)