Python process never finishing when called from Java
I've tried to setup an AI with PyTorch. Everything is fine when I call my script from the console. But when I call the script in a Java `ProcessBuildera, it will finish but never terminate...

Here is the ProcessBuilder code

String[] cmd = {"python3", "-i" , "AI/Home-System.py",
                data.getName().replace(".csv", ""),
                "true",
                "false"};
ProcessBuilder pb = new ProcessBuilder(cmd);
Process p = pb.start();


Hope that you can help me

Edit:

I found another solution. I call this script in a linux screen with

String[] cmd = {"screen", "-dmS", "AI-" + device,
                "python3", "AI/Home-System.py",
                data.getName().replace(".csv", ""),
                "true",
                "false"};
Runtime.getRuntime().exec(cmd);


Read  the process' output stream, as the end of this stream allows your ProcessBuilder to exit. Or else call the ProcessBuilder's inheritIO(). 

Then waitFor() the process.

Here is some sample code showing these steps.
