Commit ff831f21 authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

[wip] tailmode on subprocesses

parent 2c33288ef32e
......@@ -70,7 +70,7 @@ class Subprocess(AnyEntity):
v.encode(self.envencoding) if isinstance(v, unicode) else v)
for k, v in env.iteritems())
def _launch(self):
def _launch(self, tailmode=True):
"""Launch a subprocess defined.
The pid is stored in the db as soon as the subprocess is created,
......@@ -91,11 +91,17 @@ class Subprocess(AnyEntity):
self._cw.commit(free_cnxset=False)
for outname, content in communicate(proc):
self.debug('Appending %s bytes to %s (stream %s)',
len(content), outputs[outname].eid, outname)
self.info('Appending %s bytes to %s (stream %s)',
len(content), outputs[outname].eid, outname)
outputs[outname].data.write(content)
outputs[outname].cw_set(data=outputs[outname].data)
outputs[outname].data.seek(0, 2) # go to the end of stream
if tailmode:
outputs[outname].cw_set(data=outputs[outname].data)
outputs[outname].data.seek(0, 2) # go to the end of stream
self._cw.commit(free_cnxset=False)
if not tailmode:
for outname, output in outputs.items():
self.info('Flushing changes of %s to database', outname)
output.cw_set(data=output.data)
self._cw.commit(free_cnxset=False)
return proc.wait()
......
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