Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-21 Thread Donovan Baarda
On Mon, 2005-03-21 at 17:32 +1200, Greg Ewing wrote: On 18 March 2005, Donovan Baarda said: Many Python library methods and classes like select.select(), os.popen2(), and subprocess.Popen() return and/or operate on builtin file objects. However even simple applications of these methods and

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-21 Thread Peter Astrand
On Mon, 21 Mar 2005, Donovan Baarda wrote: I don't agree with that. There's no need to use non-blocking I/O when using select(), and in fact things are less confusing if you don't. You would think that... and the fact that select, popen2 etc all use file objects encourage you to think

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-21 Thread Peter Astrand
On Mon, 21 Mar 2005, Donovan Baarda wrote: The only ways to ensure that a select process does not block like this, without using non-blocking mode, are; 3) Use os.read / os.write. [...] but os.read / os.write will block too. No. Try it... replace the file read/writes in

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-21 Thread Paul Moore
On Mon, 21 Mar 2005 17:32:36 +1200, Greg Ewing [EMAIL PROTECTED] wrote: On 18 March 2005, Donovan Baarda said: The read method's current behaviour needs to be documented, so its actual behaviour can be used to differentiate between an empty non-blocking read, and EOF. This means recording

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-21 Thread Greg Ewing
Donovan Baarda wrote: Consider the following. This is pretty much the only way you can use popen2 reliably without knowing specific behaviours of the executed command; ... fcntl.fcntl(child_in, fcntl.F_SETFL, flags | os.O_NONBLOCK) # \ ... # / fcntl.fcntl(child_out,

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-21 Thread Greg Ewing
Donovan Baarda wrote: On Mon, 2005-03-21 at 17:32 +1200, Greg Ewing wrote: I don't agree with that. There's no need to use non-blocking I/O when using select(), and in fact things are less confusing if you don't. Because staller.py outputs and flushes a fragment of data smaller than selector.py

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-21 Thread Donovan Baarda
On Tue, 2005-03-22 at 12:49 +1200, Greg Ewing wrote: Donovan Baarda wrote: Consider the following. This is pretty much the only way you can use popen2 reliably without knowing specific behaviours of the executed command; ... fcntl.fcntl(child_in, fcntl.F_SETFL, flags |

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-20 Thread Donovan Baarda
On Fri, 2005-03-18 at 20:41 -0500, James Y Knight wrote: On Mar 18, 2005, at 8:19 PM, Greg Ward wrote: Is having to use fcntl and os really so awful? At least it requires the programmer to prove he knows what he's doing putting this file into non-blocking mode, and that he really wants to

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-20 Thread Greg Ewing
On 18 March 2005, Donovan Baarda said: Many Python library methods and classes like select.select(), os.popen2(), and subprocess.Popen() return and/or operate on builtin file objects. However even simple applications of these methods and classes require the files to be in non-blocking mode. I

Re: [Python-Dev] Draft PEP to make file objects support non-blocking mode.

2005-03-18 Thread James Y Knight
On Mar 18, 2005, at 8:19 PM, Greg Ward wrote: Is having to use fcntl and os really so awful? At least it requires the programmer to prove he knows what he's doing putting this file into non-blocking mode, and that he really wants to do it. ;-) I'd tend to agree. :) Moreover, I don't think