From: Xeno Campanoli Date: 2009-07-23T00:48:34+09:00 Subject: Re: timer examples Bertram Scharpf wrote: > Hi, > > Am Mittwoch, 22. Jul 2009, 07:25:14 +0900 schrieb Mathspeedy: >> I think the title says it all, >> I would like to see some timer examples, > > I examined the whole interpreter source code and could not find > any way to call alarm() or setitimer() by Ruby methods. I really > miss that! > > Bertram > > There's a Timeout method I use that has been superior to anything I could find in Python, and was a reason for me using Ruby instead at one point: > begin > Timeout::timeout(OverallTimeout) do |tl| > # Until I find out what this is, Screw it! > # No doc on tl anymore! > #puts "tl: #{tl}" > probe_threads.each { |t| t.join } > puts "All probe threads collected." > end > rescue Timeout::Error => eo > puts "#{eo.message}, exiting before joining all probe threads." > end As you see by my comment above, some of the docs are not to my satisfaction. Still, I have been using this happily since 2007. -- They are the flesh. They are the bone. They are the very cornerstone. - Janis Ian