On Thu, 10 Jun 2010 08:40:03 -0700, Chris Seberino wrote:
On Jun 10, 6:52 am, Nobody nob...@nowhere.com wrote:
Without the p1.stdout.close(), if the reader (grep) terminates before
consuming all of its input, the writer (ls) won't terminate so long as
Python retains the descriptor
On 6/10/2010 11:40 AM, Chris Seberino wrote:
Even if zombies are created, they will eventually get dealt with my OS
w/o any user intervention needed right?
Bad approach. Years ago I inherited a server that didn't do a proper cleanup pf
its slaves. After a few days running, people discovered
On Wed, 09 Jun 2010 21:15:48 -0700, Chris Seberino wrote:
How do subprocess.Popen(ls | grep foo, shell=True) with shell=False?
The same way that the shell does it, e.g.:
from subprocess import Popen, PIPE
p1 = Popen(ls, stdout=PIPE)
p2 = Popen([grep, foo], stdin=p1.stdout, stdout = PIPE
On 2010-06-10, Chris Seberino cseber...@gmail.com wrote:
How do subprocess.Popen(ls | grep foo, shell=True) with shell=False?
You'll have to build your own pipeline with multiple calls to subprocess
Does complex commands with | in them mandate shell=True?
Yes.
Hey, I've got a novel idea
On Jun 10, 6:52 am, Nobody nob...@nowhere.com wrote:
Without the p1.stdout.close(), if the reader (grep) terminates before
consuming all of its input, the writer (ls) won't terminate so long as
Python retains the descriptor corresponding to p1.stdout. In this
situation, the p1.wait() will
On 06/10/10 21:52, Nobody wrote:
Spawning child processes to perform tasks
which can easily be performed in Python is inefficient
Not necessarily so, recently I wrote a script which takes a blink of an
eye when I pipe through cat/grep to prefilter the lines before doing
further complex
On Thu, Jun 10, 2010 at 4:52 AM, Nobody nob...@nowhere.com wrote:
Also, ls | grep may provide a useful tutorial for the subprocess module,
but if you actually need to enumerate files, use e.g. os.listdir/os.walk()
and re.search/fnmatch, or glob. Spawning child processes to perform tasks
which
How do subprocess.Popen(ls | grep foo, shell=True) with shell=False?
Does complex commands with | in them mandate shell=True?
cs
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Jun 9, 2010 at 9:15 PM, Chris Seberino cseber...@gmail.com wrote:
How do subprocess.Popen(ls | grep foo, shell=True) with shell=False?
I would think:
from subprocess import Popen, PIPE
ls = Popen(ls, stdout=PIPE)
grep = Popen([grep, foo], stdin=ls.stdout)
Cheers,
Chris
--
http