In article <[EMAIL PROTECTED]>,
 Gustavo Córdova Avila <[EMAIL PROTECTED]> wrote:

> David Bolen wrote:
> 
> >Jp Calderone <[EMAIL PROTECTED]> writes:
> >
> >>    def nonBlockingReadAll(fileObj):
> >>        bytes = []
> >>        while True:
> >>            b = fileObj.read(1024)
> >>            bytes.append(b)
> >>            if len(b) < 1024:
> >>                break
> >>        return ''.join(bytes)
> >>
> >Wouldn't this still block if the input just happened to end at a
> >multiple of the read size (1024)?
> >
> >-- David
> >
> No, it'll read up to 1024 bytes or as much as it can, and
> then return an apropriatly sized string.

Depends.  I don't believe the original post mentioned
that the file is a pipe, socket or similar, but it's
kind of implied by the use of select() also mentioned.
It's also kind of implied by use of the term "block" -
disk files don't block.

If we are indeed talking about a pipe or something that
really can block, and you call fileobject.read(1024),
it will block until it gets 1024 bytes.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to