snakeoil icon indicating copy to clipboard operation
snakeoil copied to clipboard

Supporting pushing subprocess output through formatters

Open mgorny opened this issue 10 years ago • 1 comments

Long story short, pkgcore right now kinda pushes output through two separate pipesets. The 'Python part' of the output goes through formatters, while the 'bash part' (and other subprocesses) output to stdout/stderr directly. This kinda sucks when using the API e.g. to regen caches since I can only capture some of the output via API, while for the other part I need to replace file descriptors.

My idea so far is to introduce an additional property to the formatters, let's call it technically .input_stream. It would be used as stdout/stderr target for subprocess calls (where the two aren't redirected for some other reason). For regular formatters, it will be just a copy of .stream, therefore the output would still land as stdout/stderr. However, it would make it possible to have different streams in the future, e.g. to delay output when doing multi-threaded cache regen.

@ferringb, what do you think?

mgorny avatar Aug 23 '15 10:08 mgorny

I've got no argument w/ the analysis, nor proposal- my original intent was basically what you're suggesting, I just never finished it (and your description is a bit more cogent than my old design docs). cough ;)

I'm not sure about .input_stream for the naming- that may run into abstraction issues down the line if/when stdin is actually integrated (assuming we ever go that route rather than the custom crap for --ask).

ferringb avatar Aug 25 '15 01:08 ferringb