472,142 Members | 1,316 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

subprocess returncode always None

Dear All,

I'm currently working on a project that needs to collect the output of
the JHOVE application. More information about the application is
available at this website:


The application is written in Java and is executed by a shell script.
There are occasions where this application may get stuck in an
infinite loop. For this reason I've been trying to implement a simple
class that I can use to execute the JHOVE application and if it
doesn't complete in the required period of time to raise an exception
and kill the process.

The class is as follows, apologies for the odd line wrapping.

class niceSubprocess(object):
A class that implements a call to the subprocess method with a timeout
- command, the command to execute
- params, the parameters to pass to the application
- timeout, the amount of time in seconds to wait
def executeCommand(self, command, params, timeout):
timeElapsed = 0

process = subprocess.Popen((command, params), stdin =
subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE,
close_fds = True)

while process.poll() == None and timeElapsed < timeout:
print process.poll()
#print process.stdout.read()
timeElapsed = timeElapsed + 1

if process.poll() == None:
# kill off the process, and don't be terribly nice about it
os.kill(process.pid, signal.SIGKILL)
raise timeoutError, timeout
if process.stdout.read() == "":
raise executeError, process.stderr.read()
return process.stdout.read()

except Exception, errorInfo:
# pass the exception to the calling code
raise errorInfo


I'm running this on Linux and through the use of top can see the JAVA
process start and complete. The problem I have is that process.poll()
always returns None, even though the application has successfully ran
and returned output.

Can anyone shed some light on why the call to the shell script always
returns None as a return code?

With thanks.


Corey Wallis
RUBRIC Technical Officer
University of Southern Queensland
Jul 9 '06 #1
0 2277

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Christoph Haas | last post: by
4 posts views Thread by 7stud | last post: by
12 posts views Thread by bhunter | last post: by
3 posts views Thread by jakub.hrozek | last post: by
reply views Thread by Albert Hopkins | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.