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

Guido van Rossum guido at python.org
Wed Mar 7 18:55:04 CET 2007


On 3/7/07, Jim Jewett <jimjjewett at gmail.com> wrote:
> On 3/6/07, Guido van Rossum <guido at python.org> wrote:
> > I think maybe a useful simplification would be to support special
> > return values to capture EWOULDBLOCK (or equivalent) in the raw I/O
> > interface only.
>
> That makes sense.
>
> > The buffering layer could then raise IOError (or perhaps a special
> > subclass of it) if the raw I/O layer ever returned one of these;
>
> Is this a "could", or "should"?  I would expect the buffering layer
> (particularly output) to use its buffer, and to appear blocking
> (through sleep-and-retry) when that isn't enough.
>
> Or are you concerned that if it might really be blocked forever, and
> should say so at the first opportunity?

If the read can be satisifed from the buffer, or with a single raw
read call, I see no reason to return an error. But if a raw read call
is necessary and the raw read call returns None, the buffered layer
should *not* retry since that would just turn it into a busy-wait loop
until the read can be satisfied, which is a really bad idea.

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


More information about the Python-3000 mailing list