[Python-3000] Non-blocking I/O? (Draft PEP for New IO system) (original) (raw)

Guido van Rossum guido at python.org
Wed Mar 7 16:49:20 CET 2007


I don't agree with this line of reasoning. It should be a ValueError when passing a nonblocking raw I/O object to BufferedIO, but that's not detectable (at least not without an unpleasant amount of platform-specific code), and it isn't sufficient either, since the file could be blocking initially and made non-blocking later.

I/O primitives produce IOError for anything I/O-related. Something in the app has made the file nonblocking where it shouldn't. It's no different from trying to read from a low-level file descriptor that's open for writing only -- that will raise IOError too, and there's nothing we can do about it, so you better accept it than trying to fight it.

--Guido

On 3/7/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

Daniel Stutzbach wrote: > An IOError makes it more clear > that something went awry, while a ValueError typically implies that > the operation was rejected altogether.

In the code I typically write, the IOError will get reported to the user, who won't know why it happened or what to do about it, and the application will abort that operation and go on to do something else. The ValueError will cause the application to abort altogether and produce a traceback, which is as it should be, since there's a bug. In either case, it doesn't really matter whether something was written or not, as the whole operation is screwed anyway. -- Greg


Python-3000 mailing list Python-3000 at python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-3000 mailing list