From: nobu.nokada@... Date: 2002-05-10T19:48:48+09:00 Subject: Re: timeout.rb problem Hi, At Fri, 10 May 2002 19:22:30 +0900, Nikodemus Siivola wrote: > > > I am wondering if there should be a companion method, such as > > > "timebreak" that merely rudely interrupts the execution of a the block > > > instead of raising an exception. > > > Like a signal handler? > > Like: Sorry, misunderstood. > def timebreak(sec) > res = nil > sub = Thread.start { > res = yield sec > } > sleep sec # This is a bit simplistic: we should > sub.kill if sub.alive? # return before "sec" seconds if the block > return res # has finished execution, not just hang for > end # the given time... Certainly, it's good enough in the case of whether timed out or not isn't important or can be distinguished. -- Nobu Nakada