From: Bill Kelly Date: 2008-02-06T16:12:56+09:00 Subject: Re: Timeout::Error From: "Jeremy Thurgood" > Eric Hodel wrote: >> On Feb 5, 2008, at 06:20 AM, Jeremy Thurgood wrote: >> >>> Good day, >>> >>> Would it be possible to change the superclass of Timeout::Error to >>> something in StandardError? >> >> No. The exception would be rescued inappropriately then. > > At the moment it's being /not/ rescued inappropriately. Why should a > timeout exception (from within the standard libraries!) evade a naked > "rescue"? The current situation requires me to figure out everythign > that can possibly time out and add special-case error handling for it. > Worse than this, irb doesn't catch Timeout::Error and thus kills my > session (which typically has a bunch of state in it) whenever the http > server I'm talking to takes a while to respond. As an aside, you'll likely want to take great care with which parts of your code wrap with a Timeout. I don't know if this has changed in 1.9, but in 1.8, a Timeout can occur in such a way as to shortcut one or more statements in an ensure block. (Explanation with example case: http://groups.google.com/group/comp.lang.ruby/msg/2c289a0c788483da ) In short: Don't wrap any code with a timeout { } that could leave your program in a bad state if its ensure blocks were skipped. (Or the ensure blocks of any methods it calls, any methods *they* call, etc., etc.) Just FYI.. Regards, Bill