I think this is probably really a java question. I suspect that yourFor some reason i need to start a python script from inside a java code. The main part of the code is something like this
try{ Runtime rt = Runtime.getRuntime(); System.out.println("start"); Process proc = Runtime.getRuntime().exec("python myscript.py"); proc.waitFor(); System.out.println("end"); } catch (Exception e){ e.printStackTrace(); }
and so worked for months....but since some days ago the same instruction does not work but execute without any exception, that is print either "start" and "end"; the strangest thing happen when I call just
Process proc = Runtime.getRuntime().exec("python myscript.py");
the execution looks like stalled and does not comes to an end printing just the "start".
Some suggestion? My machine is a Linux Mandrake64 10.1
python script is issuing too much output either on stdout or stderr,
and because you are not reading these streams, the process is blocking
because the output buffers are full. If this is the case, you need to get your java program to read the streams (Process.getInputStream()
and Process.getErrorStream()), which is something you should be doing
anyway. In order to read both streams, you either need two threads, or
to use java.nio and select.
A short term fix might be to run theh python script by hand and see if it throws out a long stack trace (this could block an unread error stream).
HTH Steve -- http://mail.python.org/mailman/listinfo/python-list