void (ConsoleCodeFragment code, final Function<InterpreterResponse, Object> callback) { isExecuting = true; if (waitingForInput) { final OutputStream processInput = myDebugProcess.getProcessHandler().getProcessInput(); if (processInput != null) { try { final Charset defaultCharset = EncodingProjectManager.getInstance(myDebugProcess.getProject()).getDefaultCharset(); processInput.write((code.getText()).getBytes(defaultCharset)); processInput.flush(); } catch (IOException e) { LOG.error(e.getMessage()); } } myNeedsMore = false; isExecuting = false; waitingForInput = false; notifyCommandExecuted(waitingForInput); } else { exec(new ConsoleCodeFragment(code.getText(), false), new PyDebugCallback<>() { @Override public void ok(Pair<String, Boolean> executed) { boolean more = executed.second; myNeedsMore = more; isExecuting = false; notifyCommandExecuted(more); callback.fun(new InterpreterResponse(more, isWaitingForInput())); } @Override public void error(PyDebuggerException exception) { myNeedsMore = false; isExecuting = false; notifyCommandExecuted(false); callback.fun(new InterpreterResponse(false, isWaitingForInput())); } }); } }