amoffat/pbs — Issue #26: Standard file descriptors should work as generators
Author: pcn
Created: 2012-02-02 16:59:49+00:00
State: open

I've implemented a test at https://github.com/pcn/pbs in the generator branch. I think it's clumsy, but I'm still feeling my way around.

Use case:

Do something useful with vmstat, tcpdump, etc. These commands are most useful when producing output constantly, and pbs should be able to consume these line by line.

The implementation avoids calling subprocess.communicate and selects directly from the pbs_object.process objects stdout.

I'm looking for thoughts on how to do this "right" (e.g. should it be a subclass or a separate module that inherits from pbs?). Currently it changes how it's used, but it is convenient because if only the last command in a pipeline has _generator=True set, then everything should work as normal (once I hook stdin back up :) except the last command will yield lines that can be worked with.