[Python-3000] Draft PEP for New IO system

Daniel Stutzbach daniel.stutzbach at gmail.com
Wed Feb 28 17:00:58 CET 2007

What should Buffered I/O .write() do for a non-blocking object?

It seems like the .write() should write as much as it can to the Raw
I/O object and buffer the rest, but then how do we tell the Buffered
I/O object to "write more data from the buffer but still don't block"?

Along the same lines, for a non-blocking Buffer I/O object, how do we
specify "Okay, I know I've been writing only one byte a time so you
probably haven't bothered writing it to the raw object.  Write as much
data as you can now, but don't block".

Option #1: On a non-blocking object, .flush() writes as much as it
can, but won't block.  It would need a return value then, to indicate
whether the flush completed or not.

Option #2: Calling .write() with no arguments causes the Buffer I/O
object to flush as much write data to the raw object, but won't block.
 (For a blocking object, it would block until all data is written to
the raw object).

I prefer option #2 because a .flush() that doesn't flush is more surprising.

The goal of supporting non-blocking file-like objects is to be able to
use select() with buffered I/O objects (and other things like a
compressed socket stream).

Daniel Stutzbach, Ph.D.             President, Stutzbach Enterprises LLC

More information about the Python-3000 mailing list