From: Nikodemus Siivola Date: 2002-05-10T06:56:16+09:00 Subject: timeout.rb problem Nested timeouts considered nasty ;) The scripts below prints out "achived enlightenment, exiting gracefully...", which is in this context quite understandable -- but extremely surprising if the inner timeout is "more distant", in a library module for example. #!/usr/bin/ruby require 'timeout' def meditate begin timeout(10) { loop { self.inspect } } rescue TimeoutError puts "achived enlightenment, exiting gracefully..." exit end end def try_to_meditate begin timeout(1) { meditate } rescue TimeoutError puts "meditation takes too long, rush to abort!" abort end end try_to_meditate __END__ - Is this technically correct? Should a rescue block rescue an exception that is raised from outside of it's scope? - Is this really the way timeout's should behave? Maybe TimeoutError could contain information of it's nesting level so that when rescuing a timeout one could reraise it so that the higher level code would have a chance to rescue it too... - Is this a timeout problem, a thread problem or an exception problem? -- Nikodemus