Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7350 jvm python magic extended to other kernels #7364

Merged
merged 5 commits into from
May 16, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
#7350 kernel magic - fix for synchronization with py4j server
  • Loading branch information
Lukasz Mitusinski committed May 16, 2018
commit 188d0fb0aecac566f93de905f6a53df032a38d99
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class MagicKernelManager {
private static String DEFAULT_PORT = "25333";
private static String DEFAULT_PYTHON_PORT = "25334";
private static int NO_SUCH_KERNEL_CODE = 2;
private static String PY4J_INIT_MESSAGE = "Py4j server is running";

private Integer port = null;
private Integer pythonPort = null;
Expand All @@ -62,13 +63,14 @@ private void initPythonProcess() throws NoSuchKernelException {
ProcessBuilder pb = new ProcessBuilder(getPy4jCommand());
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
pythonProcess = pb.start();
//wait for python process to initialize properly
new BufferedReader(new InputStreamReader(pythonProcess.getInputStream())).readLine();
Thread.sleep(1);
BufferedReader br = new BufferedReader(new InputStreamReader(pythonProcess.getInputStream()));
while (!PY4J_INIT_MESSAGE.equals(br.readLine()) && pythonProcess.isAlive()){
//wait for python process to initialize properly
}
if (!pythonProcess.isAlive() && pythonProcess.exitValue() == NO_SUCH_KERNEL_CODE) {
throw new NoSuchKernelException(kernelName);
}
} catch (IOException | InterruptedException e) {
} catch (IOException e) {
e.printStackTrace();
}
}
Expand Down