Need to move on after java error when Python script uses subprocess to run a java program -


in python2.7 script, i'm using subprocess.call run java program this:

java_command = "java -jar /path/to/java_program.jar %s %s >> %s" % (infile, outfile, logfile) subprocess.call(java_command, shell=true) ... #do other stuff unrelated output 

most of time, works fine, in cases java program errs:

exception in thread "main" java.lang.nullpointerexception     @ myprogram.mainwindow.setprocessing(mainwindow.java:288) 

the problem python script stalled on subprocess.call() line , can't "other stuff".

is there way can edit either java_command i'm using or way i'm using subprocess continue python script when java program hangs?

note can't modify java program's code.

i think want check_call method same package:

try:     status = subprocess.check_call(java_command, shell=true) except calledprocesserror e:     # exception object contains return code ,     # other failure information.     ... react failure , recover 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -