H
Harold Hausman
Here's my code. It's dumb:
require 'open-uri'
begin
=09while true do
=09=09the_begin_time =3D Time.now
=09=09open( "http://danceliquid.com/test/public/" ) do |stuff|
=09=09=09puts stuff.read
=09=09end
=09=09the_wait_time =3D Time.now - the_begin_time
=09=09the_file =3D File.new("SitePingLog.txt", "a")
=09=09the_file.puts('Got it in '+ the_wait_time.to_s + ' seconds @ ' +
Time.now.to_s)
=09=09the_file.close
=09=09sleep 600
=09end
rescue
=09=09the_file =3D File.new("SitePingLog.txt", "a")
=09=09the_file.puts(Error @ ' + Time.now.to_s)
=09=09the_file.close
=09=09retry
end
#What it does it hit my site every ten minutes, and keep a log of how
long it took to get the content there. I was having people tell me
that intermittently they wouldn't be able to get to it at all, or
sometimes it would be really slow. This script has proven this to be
true, and in all honesty I'm not too worried about the performance of
my site. My question is, all the open-uri code is inside the begin,
rescue section, and occasionally the rescue, end section gets called,
but also sometimes (infrequently), the whole script bombs out...
here's the error:
c:/ruby/lib/ruby/1.8/timeout.rb:42:in `rbuf_fill': execution expired (Timeo=
ut::E
rror)
from c:/ruby/lib/ruby/1.8/net/protocol.rb:196:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:196:in `rbuf_fill'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:160:in `readuntil'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:171:in `readline'
from c:/ruby/lib/ruby/1.8/net/http.rb:1554:in `read_status_line'
from c:/ruby/lib/ruby/1.8/net/http.rb:1538:in `read_new'
from c:/ruby/lib/ruby/1.8/net/http.rb:833:in `request'
... 9 levels...
from c:/ruby/lib/ruby/1.8/open-uri.rb:134:in `open_uri'
from c:/ruby/lib/ruby/1.8/open-uri.rb:424:in `open'
from c:/ruby/lib/ruby/1.8/open-uri.rb:85:in `open'
from C:/Documents and Settings/Harold/Desktop/scripting/ruby/SitePi=
nger.
rb:5
... Right, so, isin't begin, rescue, end supposed to stop exactly this
from happening? Or chances are, I've misunderstood.
Thanks in advance for your time,
-Harold
require 'open-uri'
begin
=09while true do
=09=09the_begin_time =3D Time.now
=09=09open( "http://danceliquid.com/test/public/" ) do |stuff|
=09=09=09puts stuff.read
=09=09end
=09=09the_wait_time =3D Time.now - the_begin_time
=09=09the_file =3D File.new("SitePingLog.txt", "a")
=09=09the_file.puts('Got it in '+ the_wait_time.to_s + ' seconds @ ' +
Time.now.to_s)
=09=09the_file.close
=09=09sleep 600
=09end
rescue
=09=09the_file =3D File.new("SitePingLog.txt", "a")
=09=09the_file.puts(Error @ ' + Time.now.to_s)
=09=09the_file.close
=09=09retry
end
#What it does it hit my site every ten minutes, and keep a log of how
long it took to get the content there. I was having people tell me
that intermittently they wouldn't be able to get to it at all, or
sometimes it would be really slow. This script has proven this to be
true, and in all honesty I'm not too worried about the performance of
my site. My question is, all the open-uri code is inside the begin,
rescue section, and occasionally the rescue, end section gets called,
but also sometimes (infrequently), the whole script bombs out...
here's the error:
c:/ruby/lib/ruby/1.8/timeout.rb:42:in `rbuf_fill': execution expired (Timeo=
ut::E
rror)
from c:/ruby/lib/ruby/1.8/net/protocol.rb:196:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:196:in `rbuf_fill'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:160:in `readuntil'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:171:in `readline'
from c:/ruby/lib/ruby/1.8/net/http.rb:1554:in `read_status_line'
from c:/ruby/lib/ruby/1.8/net/http.rb:1538:in `read_new'
from c:/ruby/lib/ruby/1.8/net/http.rb:833:in `request'
... 9 levels...
from c:/ruby/lib/ruby/1.8/open-uri.rb:134:in `open_uri'
from c:/ruby/lib/ruby/1.8/open-uri.rb:424:in `open'
from c:/ruby/lib/ruby/1.8/open-uri.rb:85:in `open'
from C:/Documents and Settings/Harold/Desktop/scripting/ruby/SitePi=
nger.
rb:5
... Right, so, isin't begin, rescue, end supposed to stop exactly this
from happening? Or chances are, I've misunderstood.
Thanks in advance for your time,
-Harold