Hi everyone,

I'm new to Ruby but familiar with some other programming and scripting
languages. I like what I see so far.

My question is how to resume execution of a FOR loop, after a certain
time has elapsed. Some pseudo-code appears below.

I'm testing the performance of a website using WATIR, by running the
same test script multiple times ("for i in 1..1000") and logging the
results. This works fine, except in cases when the entire site freezes
(it's not a very robust site, hence the testing).

I'd like to be able to run the test overnight, and have Ruby
automatically cancel the current iteration of the FOR loop after (say)
10 minutes.

Currently, the script will wait for the browser's error dialog to be
dismissed if the site crashes during the test. I'd like to close the
browser and open a new instance in this case.

Thanks,
Steve

require 'timeout'
for i in 1..1000
  status = Timeout::timeout(60) {
    b = Firefox.new
    b.goto "some site"
    #1. perform some processing, which should take less than 60 seconds
    #2. if the process was successful, write the result to a text file
    #3. if it took too long, abort this iteration, and continue with
"next i"
    b.close
  }
end
-- 
Posted via http://www.ruby-forum.com/.