[Wtr-general] IE.GoTo - Can You Set A Timeout or an Idle?

Chris McMahon christopher.mcmahon at gmail.com
Thu Oct 12 16:52:05 EDT 2006


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20061012/95ea3c36/attachment-0001.html 


More information about the Wtr-general mailing list