Straight outta the pickaxe (with comments from me),
does this work?
(http://www.rubycentral.com/book/lib_standard.html)
require "timeout"
for snooze in 1..2
puts "About to sleep for #{snooze}"
timeout(1.5) do
sleep(snooze)
#ie.goto(http://foo.com)
end
puts "That was refreshing"
#puts "went to foo.com in less than 1.5 seconds)
end
produces:
About to sleep for 1 That was refreshing About to sleep for 2 /tc/usr/lib/ruby/1.6/timeout.rb:37: execution expired (TimeoutError) from prog.rb:5:in `timeout' from prog.rb:5 from prog.rb
:3:in `each' from prog.rb:3
|
The
timeout method takes a single parameter, representing
a timeout period in seconds, and a block. The block is executed, and
a timer is run concurrently. If the block terminates before the
timeout,
timeout returns
true. Otherwise, a
TimeoutError exception is raised.
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general