I run a python script from
Java, and the using a BufferedReader, I read the input. Up until now it was running perfectly. All of a sudden, it seems in certain functions of my python script, it is no longer giving me any output until the script has finished.
Here a shortened version of my java code:
And the python code can simply be:
It's a very simplified version of what is happening in one of my python functions.
What I would expect the output in Java to be is:
line 1
..... // a very long wait
line 4
In "real time" - so when the python prints a message, it appears in Java as quick as possible. What actually happens is that nothing is printed until the for loop has finished running. Not even the "line 1" will appear even though it is before the for loop. Correct me if i'm wrong, but because it's a buffered reader is (blocking?) buffering the input. Normally I would use a .flush() method but the buffered reader doesn't have that
How can I change this so as soon as python prints a message, Java will print that message as well?