From: Marcin Coles Date: 2007-05-01T11:29:57+09:00 Subject: Re: Timeout errors using Net::HTTP on Windows 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 Toby Dipasquale wrote: > Emilio Tagua wrote: >> On 4/17/07, Toby DiPasquale wrote: >>> from put_client.rb:25:in `upload_file' >>> uri = URI.parse url >>> else >>> end >>> require 'webrick' >>> s.mount("/", PutServlet) >>> Any ideas? Thanks. >> You could try something like: >> def method >> begin >> response = Timeout::timeout(5) { Net::(whatever u want from NET >> Class) } >> ... >> rescue Timeout::Error >> puts 'Timeout!!!' >> .... >> end >> end >> >> Hope it helps you! > > This would not help as the problem it the use of the timeout module in > the first place. The net/protocol module already wraps the call in a > Timeout::timeout() call and this is the source of the issue. That call > spawns a Ruby thread to enforce the timeout and the combination of the > thread use and I/O is what is triggering the problem. In any case, I've > already rewritten the code in Python and it works fine on all platforms. > Thanks anyway. > > -- > Toby DiPasquale -- Posted via http://www.ruby-forum.com/.