ZEPPELIN-4062. Don't wait ipython kernel if python process failed

This commit is contained in:
Jeff Zhang 2019-03-13 10:31:00 +08:00
parent 3c7f0093f4
commit 130c2a82a0

View file

@ -82,6 +82,7 @@ public class IPythonInterpreter extends Interpreter implements ExecuteResultHand
private boolean useBuiltinPy4j = true;
private boolean usePy4JAuth = true;
private String secret;
private volatile boolean pythonProcessFailed = false;
private InterpreterOutputStream interpreterOutput = new InterpreterOutputStream(LOGGER);
@ -293,7 +294,7 @@ public class IPythonInterpreter extends Interpreter implements ExecuteResultHand
// wait until IPython kernel is started or timeout
long startTime = System.currentTimeMillis();
while (true) {
while (!pythonProcessFailed) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
@ -318,6 +319,9 @@ public class IPythonInterpreter extends Interpreter implements ExecuteResultHand
+ " seconds");
}
}
if (pythonProcessFailed) {
throw new IOException("Fail to launch IPython Kernel as the python process is failed");
}
}
protected Map<String, String> setupIPythonEnv() throws IOException {
@ -417,6 +421,7 @@ public class IPythonInterpreter extends Interpreter implements ExecuteResultHand
@Override
public void onProcessFailed(ExecuteException e) {
LOGGER.warn("Exception happens in Python Process", e);
pythonProcessFailed = true;
}
static class ProcessLogOutputStream extends LogOutputStream {