private @NotNull Promise<XDebugSession> createSessionUsingTargetsApi(@NotNull RunProfileState state,
                                                                       final @NotNull ExecutionEnvironment environment) {
    PythonCommandLineState pyState = (PythonCommandLineState)state;
    RunProfile profile = environment.getRunProfile();
    var clientId = ClientId.getCurrentOrNull();
    return Promises
      .runAsync(() -> {
        int serverLocalPort = findAvailableSocketPort();
        try {
          PythonDebuggerScriptTargetedCommandLineBuilder debuggerScriptCommandLineBuilder =
            new PythonDebuggerScriptTargetedCommandLineBuilder(environment.getProject(), pyState, profile, serverLocalPort);
          ExecutionResult result = pyState.execute(environment.getExecutor(), debuggerScriptCommandLineBuilder);
          ServerSocket serverSocket = debuggerScriptCommandLineBuilder.getServerSocketForDebugging();
          if (serverSocket == null) {
            LOG.error("The server socket has not been created after the target environment preparation" +
                      ", trying to fallback and create the server socket on the loopback address");
            serverSocket = createServerSocketOnLoopbackAddress(serverLocalPort);
          }
          return Pair.create(serverSocket, result);
        }
        catch (ExecutionException err) {
          throw new RuntimeException(err.getMessage(), err);
        }
      })
      .thenAsync(pair -> AppUIExecutor.onUiThread().submit(() -> {
        try (AccessToken ignored = ClientId.withClientId(clientId)) {
          ServerSocket serverSocket = pair.getFirst();
          ExecutionResult result = pair.getSecond();
          return createXDebugSession(environment, pyState, serverSocket, result);
        }
      }));
  }
private @NotNull Promise<XDebugSession> createSessionUsingTargetsApi(@NotNull RunProfileState state,
                                                                       final @NotNull ExecutionEnvironment environment)