[Python-3000] iostack and sock2

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jun 6 15:27:44 CEST 2006


Ronald Oussoren wrote:

> I'm slighly worried about this thread. Async I/O and "read exactly N  
> bytes" don't really match up. I don't know about the other  mechanisms, 
> but at least with select and poll when the system says  you can read 
> from a file descriptor you're only guaranteed that one  call to 
> read(2)/recv(2)/... won't block. The implementation of a  python read 
> method that returns exactly the number of bytes that you  requested will 
> have to call the read system call in a loop and hence  might block.

This is one case where the callback model of async i/o may
help. If there were a way to say "don't call me until you've
got n bytes ready", the descriptor could become ready
multiple times and multiple reads performed behind the
scenes, then when enough bytes are there, your callback
is called.

--
Greg




More information about the Python-3000 mailing list