non blocking read()

David Bolen db3l at fitlinxx.com
Wed Dec 1 15:55:18 EST 2004


Jp Calderone <exarkun at divmod.com> 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



More information about the Python-list mailing list