How can I know how much to read from a subprocess

A.T.Hofkamp hat at se-162.se.wtb.tue.nl
Tue Sep 18 12:48:49 CEST 2007


On 2007-09-17, spam.noam at gmail.com <spam.noam at gmail.com> wrote:
> It seems that another solution is gobject.io_add_watch, but I don't
> see how it tells me how much I can read from the file - if I don't
> know that, I won't know the argument to give to the read() method in
> order to get all the data:
>
> http://www.pygtk.org/docs/pygobject/gobject-functions.html#function-gobject--io-add-watch
>

Usually, gobject only tells you that data is there (that is all it knows).
Therefore a read(1) should be safe.
If that is too slow, consider os.read() which reads all data available (afaik,
never tried it myself).

Albert



More information about the Python-list mailing list