Mercurial > hg > config
changeset 607:567492ef7b57
STUB: python/multiproc.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 02 Feb 2014 11:16:51 -0800 |
parents | 5b561c7b2005 |
children | 9a5cdd49af53 |
files | python/multiproc.py |
diffstat | 1 files changed, 11 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/python/multiproc.py Sun Feb 02 11:07:04 2014 -0800 +++ b/python/multiproc.py Sun Feb 02 11:16:51 2014 -0800 @@ -27,6 +27,11 @@ _kwargs = self.defaults.copy() _kwargs.update(kwargs) + # on unix, ``shell={True|False}`` should always come from the + # type of command (string or list) + if not mswindows: + _kwargs['shell'] = isinstance(command, string) + # output buffer self.output_buffer = tempfile.SpooledTemporaryFile() self.location = 0 @@ -35,7 +40,7 @@ # launch subprocess self.start = time.time() - subprocess.Popen.__init__(self, *args, **_kwargs) + subprocess.Popen.__init__(self, command, **_kwargs) def wait(self, maxtime=None, sleep=1.): """ @@ -51,14 +56,15 @@ # TODO: read from output return process.kill() + # read from output buffer + self.output_buffer.seek(self.location) + read = self.output_buffer.read() + self.location += len(read) + # naptime if sleep: time.sleep(sleep) - # read from output buffer - self.output_buffer.seek(self.location) - read = self.output_buffer.read() - self.location += len(read) def commandline(self): """returns string of command line"""