From: Minero Aoki Date: 2001-12-31T02:37:24+09:00 Subject: [ruby-talk:29731] Re: http timeout? In mail "[ruby-talk:29729] Re: http timeout?" "Mark Hahn" wrote: > > Sould I set timeout limit by default? > > Yes. A call that never returns is a bad thing. The timeouts you suggested > would be great. OK. I set it. > Using only pickaxe, I had no way of knowing about the timeout methods. For > some reason the Protocol module is not documented. Major reason is that *I* had not describe all methods concisely. Current version is better, but still not insufficient. sigh. > Can you answer my question about what happens to a socket when the thread is > killed? If a socket/Net::HTTP object is refered only from the stack, it is closed on next GC (maybe this is not good thing). Throwing exceptions into other thread is little better because Net::HTTP object will get chance to close sockets by himself. th = Thread.fork { sleep 30 ### We could not read whole page in 30 seconds Thread.main.raise 'timeout' } page = Net::HTTP.get('/index.html') th.kill # We get page, so stop timer thread. (Net::HTTP uses select(2) to check timeout. not threads.) -- Minero Aoki