D
Dan
I write a lot of scripts that I run once or infrequently that uses open-rui=
Occasionally I run into a web site that times out or is unavailable for a=
period of time. My normal solution is to just rerun the script manually at=
a later time and the problem goes away. What I would like to start doing i=
s rescuing the open() and retrying the open() after a delay. What would be =
the most idiomatic way to try opening a url say n times before giving up? H=
ere is my crude code for trying twice:
begin=A0=20
=A0=A0 open("http://www.example.com/foo.html")
=A0rescue=A0=20
=A0=A0 begin=A0=20
=A0=A0=A0=A0=A0 open("http://www.example.com/foo.html")
=A0=A0=A0 rescue=A0=20
=A0=A0=A0=A0=A0 #tried twice - giving up=A0=20
=A0=A0 end=A0=20
end=A0=20
I would like a more general approach using ruby idioms where I could specif=
y the maximum number of attempts and delay before giving up. Thanks for you=
r help.
Occasionally I run into a web site that times out or is unavailable for a=
period of time. My normal solution is to just rerun the script manually at=
a later time and the problem goes away. What I would like to start doing i=
s rescuing the open() and retrying the open() after a delay. What would be =
the most idiomatic way to try opening a url say n times before giving up? H=
ere is my crude code for trying twice:
begin=A0=20
=A0=A0 open("http://www.example.com/foo.html")
=A0rescue=A0=20
=A0=A0 begin=A0=20
=A0=A0=A0=A0=A0 open("http://www.example.com/foo.html")
=A0=A0=A0 rescue=A0=20
=A0=A0=A0=A0=A0 #tried twice - giving up=A0=20
=A0=A0 end=A0=20
end=A0=20
I would like a more general approach using ruby idioms where I could specif=
y the maximum number of attempts and delay before giving up. Thanks for you=
r help.