[Python-3000] iostack and sock2

tomer filiba tomerfiliba at gmail.com
Mon Jun 5 18:36:30 CEST 2006


> 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.

it's a convenience method. instead of doing it yourself everytime,
readavail() returns all the available data in the socket's buffers.

the basic interface should be simple and spartan, but does that
mean every deriving class must not extend it? from personal experience,
of myself and others i've worked with, i can tell you readavail() would
be very useful. for reference, .NET sockets has it. so of course .NET
is NOT a model of great design, but it does show you trends and needs
of programmers.

> 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).

yes, that's how i'd do it, but then how would you wait for
multiple streams?

compare
select([sock1, sock2, sock3], [], [])
to
sock1.async_read(100, callback)

how can you block/wait for multiple streams?


-tomer

On 6/5/06, Greg Ewing < greg.ewing at canterbury.ac.nz> wrote:
>
> 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
> class.
>
> > 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
> concerned.
>
> --
> Greg
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060605/77c3b07a/attachment.html 


More information about the Python-3000 mailing list