Can read() be non-blocking?
saju.pillai at gmail.com
saju.pillai at gmail.com
Fri Nov 7 00:03:05 EST 2008
On Nov 7, 9:09 am, Lawrence D'Oliveiro <l... at geek-
central.gen.new_zealand> wrote:
> In message <gf07sh$in... at lust.ihug.co.nz>, Lawrence D'Oliveiro wrote:
>
> > In message <mailman.3600.1226012406.3487.python-l... at python.org>, Thomas
> > Christensen wrote:
>
> >> r = select.select([proc.stdout.fileno()], [], [], 5)[0]
> >> if r:
> >> # NOTE: This will block since it reads until EOF
> >> data = proc.stdout.read()
>
> > No, it will read what data is available.
>
> Sorry, maybe not. But you can set O_NOBLOCK on the fd.
Set O_NONBLOCK on proc.fileno() and try using os.read() on that
descriptor.
-srp
More information about the Python-list
mailing list