Commit 49590b90 authored by Charles Ferguson's avatar Charles Ferguson
Browse files

Add returncode property; fix iteration terminating early.

The returncode is a useful property to be able to pull out.
The iteration would terminate early if the process had already exited
by the time that the call was made. We now follow the documentation
and return the results until the buffer is empty.
parent aa44ed2b
...@@ -250,6 +250,12 @@ class StreamedInput(object): ...@@ -250,6 +250,12 @@ class StreamedInput(object):
raise StreamedInputNotStartedError("StreamedInput object cannot be sent data before starting") raise StreamedInputNotStartedError("StreamedInput object cannot be sent data before starting")
self.proc.stdin.write(string) self.proc.stdin.write(string)
@property
def returncode(self):
if not self.proc:
return None
return self.proc.returncode
def _terminate(self): def _terminate(self):
""" """
Internal call to issue a TERM signal to the subprocess. Internal call to issue a TERM signal to the subprocess.
...@@ -320,7 +326,7 @@ class StreamedInput(object): ...@@ -320,7 +326,7 @@ class StreamedInput(object):
if self.proc is None: if self.proc is None:
raise StreamedInputNotStartedError("StreamedInput object cannot be enumerated before starting") raise StreamedInputNotStartedError("StreamedInput object cannot be enumerated before starting")
while not self.proc.poll() and len(self): while len(self):
item = self.read() item = self.read()
if not item: if not item:
break break
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment