Re: what happens to Popen()'s parent-side file descriptors?

2010-10-15 Thread Nobody
On Thu, 14 Oct 2010 08:48:45 -0700, Roger Davis wrote: On a related point here, I have one case where I need to replace the shell construct externalprog somefile otherfile I suppose I could just use os.system() here but I'd rather keep the Unix shell completely out of the picture

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-15 Thread Lawrence D'Oliveiro
In message i968f501...@news6.newsguy.com, Chris Torek wrote: Running the above code fragment in a different implementation, in which garbage collection is deferred, would *not* close the file descriptor, and the system would potentially run out (depending on when a gc occurred, and/or whether

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-15 Thread Lawrence D'Oliveiro
In message 8bec27dd-b1da-4aa3-81e8-9665db040...@n40g2000vbb.googlegroups.com, Roger Davis wrote: Documentation on python.org states that GC can be postponed or omitted altogether ... Yes, but no sensible Python implementation would do that, as it’s a recipe for resource bloat. --

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-15 Thread Lawrence D'Oliveiro
In message pan.2010.10.15.06.27.02.360...@nowhere.com, Nobody wrote: Another gotcha regarding pipes: the reader only sees EOF once there are no writers, i.e. when the *last* writer closes their end. Been there, been bitten by that. -- http://mail.python.org/mailman/listinfo/python-list

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-15 Thread Chris Torek
In message pan.2010.10.15.06.27.02.360...@nowhere.com, Nobody wrote: Another gotcha regarding pipes: the reader only sees EOF once there are no writers, i.e. when the *last* writer closes their end. In article i9atra$j4...@lust.ihug.co.nz Lawrence D'Oliveiro l...@geek-central.gen.new_zealand

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-14 Thread Chris Torek
In article b166181a-2aba-4c3a-948d-674755459...@c10g2000yqh.googlegroups.com Roger Davis r...@hawaii.edu wrote: My understanding is that this functionality is best coded via subprocess.Popen(). Best is always a big question mark. :-) I need to read output from these spawned children via a pipe

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-14 Thread Roger Davis
Many thanks to all who responded to my question! It's nice to know, as someone new to Python, that there are lots of well-informed people out there willing to help with such issues. Thanks, Mike, for your pipes suggestion, I will keep that in mind for future projects. Seebs, you are of course

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-14 Thread Chris Torek
In article 8bec27dd-b1da-4aa3-81e8-9665db040...@n40g2000vbb.googlegroups.com 'Nobody' (clearly a misnomer!) and Chris, thanks for your excellent explanations about garbage collection. (Chris, I believe you must have spent more time looking at the subprocess source and writing your response than I

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-14 Thread Seebs
On 2010-10-14, Roger Davis r...@hawaii.edu wrote: Seebs, you are of course correct that the example I quoted (`cat | grep | whatever`) is best done internally with the re module and built- in language features, and in fact that has already been done wherever possible. I should have picked a

what happens to Popen()'s parent-side file descriptors?

2010-10-13 Thread Roger Davis
Hi, I am new to this group, please forgive me if this is a repeat question. I am a new Python programmer but experienced in C/Unix. I am converting a shell script to Python which essentially loops infinitely, each pass through the loop running commands like set output = `cat this | grep

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-13 Thread Mike Kent
You might want to check out the Python 2.7 'pipes' standard library module: http://docs.python.org/library/pipes.html -- http://mail.python.org/mailman/listinfo/python-list

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-13 Thread Seebs
On 2010-10-13, Roger Davis r...@hawaii.edu wrote: Hi, I am new to this group, please forgive me if this is a repeat question. I am a new Python programmer but experienced in C/Unix. I am converting a shell script to Python which essentially loops infinitely, each pass through the loop running

Re: what happens to Popen()'s parent-side file descriptors?

2010-10-13 Thread Nobody
On Wed, 13 Oct 2010 14:58:57 -0700, Roger Davis wrote: My understanding is that this functionality is best coded via subprocess.Popen(). I need to read output from these spawned children via a pipe from their stdout, hence something like p= subprocess.Popen(args,