[Python-3000] iostack and sock2

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Jun 5 00:52:07 CEST 2006

tomer filiba wrote:

> NetworkStreams have a readavail() method, which reads all the available
> in-queue data, as well as a may_read and a may_write properties

I'm -1 on having multiple kinds of read methods which
are available only on some kinds of streams. The
basic interface of a stream should be dirt simple.

Given a read-up-to-n-bytes method, it's easy to implement
read-exactly-n-bytes on top of it in a completely
generic way. So provide it as a function that operates
on a stream, or a method inherited from a generic base

> maybe introduce a new select module that has select-objects, like
> the Poll() class, that will default to using select(), but could use
> kqueue/epoll when possible?

My current opinion on select-like functionality is
that you shouldn't need to import a module for it at
all. Rather, you should be able to attach a callback
directly to a stream. Then there just needs to be
a wait_for_something_to_happen() function somewhere
(perhaps with a timeout).

Underneath, the implementation would use select,
poll, or whatever is most fun on the platform


More information about the Python-3000 mailing list