Hey Ben
I'm glad it worked for you too, and thanks for the compliment.  I was 
happy to just get rid of those untrappable errors, so I didn't even 
profile to see whether there were any other speed improvements - 
performance is not a critical issue in my script.

Cheers,
M

Ben Brightwell wrote:
> Interesting results!!! What an understatement!! How on earth did you 
> figure that out? It worked like a charm. Initially my problem was just 
> that the HTTP request took FOREVER... then i started randomly getting 
> the timeout errors mentioned above. I went into the net/protocol.rb file 
> and made this change and voila!. Not only did the errors go away, but 
> the request takes literally 1/30th of the time it did before it 
> eventually got the data or even timed out.. Marcin Coles, you are the 
> genius of the day! Thank you!
> 
> Marcin Coles wrote:
>> Well, I'm no expert, and I certainly wasn't going to learn another 
>> language, so I decided to do some tests because this was a problem for 
>> me too.
>> 
>> I went into protocol.rb, to the rbuf_fill method (where it actually 
>> starts the timeout thread).
>> 
>> the code there was
>> 
>> def rbuf_fill
>>       timeout(@read_timeout)  {
>>         @rbuf << @io.sysread(1024)
>>       }
>> end
>> 
>> now timeout takes 2 parameters - a time in seconds(?) and an exception 
>> class to raise (defaults to Error).
>> 
>> When I changed the code to the following, it started to work for me. 
>> New code:
>> 
>> def rbuf_fill
>>       timeout(@read_timeout,ProtocolError) {
>>         @rbuf << @io.sysread(1024)
>>       }
>> end
>> 
>> Obviously this is not exactly extensively tested - but an interesting 
>> results.
>> 
>> Marcin


-- 
Posted via http://www.ruby-forum.com/.