On 2007-09-18, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Sep 18, 1:48 pm, "A.T.Hofkamp" <[EMAIL PROTECTED]> wrote:
>> On 2007-09-17, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 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-g...
>>
>> Usually, gobject only tells you that data is there (that is all it knows).
>> Therefore a read(1) should be safe.
>
> But even if it's fast enough, how do you know how many times you
> should call read(1)? If you do it too much, you'll be blocked until
> more output is available.

after reading 1 byte, wait for gobject again.

In other words, when gobject sends a notice, read 1 byte.
When there is more, gobject will tell you (probably very often :-) ).


>
>> If that is too slow, consider os.read() which reads all data available 
>> (afaik,
>> never tried it myself).
>>
> I tried it now, and it blocks just like the normal file.read().

So "os.read(handle.fileno(), 1000000)" blocks after gobject tells you there is 
data?
That is different than I heard, but you are probably correct, I cannot easily 
test this.


Albert
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to