void (final @ProgressText String connectionMessage, @ProgressTitle String connectionTitle) { ProgressManager.getInstance().run(new Task.Backgroundable(getSession().getProject(), connectionTitle, false) { @Override public void run(@NotNull final ProgressIndicator indicator) { indicator.setText(connectionMessage); try { beforeConnect(); myWaitingForConnection = true; myDebugger.waitForConnect(); myWaitingForConnection = false; afterConnect(); handshake(); init(); myDebugger.run(); } catch (final Exception e) { myWaitingForConnection = false; if (myProcessHandler != null) { myProcessHandler.destroyProcess(); } if (shouldLogConnectionException(e)) { PyDebugProcess.getNotificationGroup() .createNotification(PyBundle.message("debug.notification.title.connection.failed"), e.getMessage(), NotificationType.ERROR) .notify(myProject); } } } }); }