<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Timing out and retrying calls to third parties</title>
	<atom:link href="http://www.sitepoint.com/blogs/2006/08/24/timing-out-and-retrying-calls-to-third-parties/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2006/08/24/timing-out-and-retrying-calls-to-third-parties/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<pubDate>Thu, 04 Dec 2008 03:18:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: timlucas</title>
		<link>http://www.sitepoint.com/blogs/2006/08/24/timing-out-and-retrying-calls-to-third-parties/#comment-47350</link>
		<dc:creator>timlucas</dc:creator>
		<pubDate>Thu, 24 Aug 2006 00:42:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1684#comment-47350</guid>
		<description>Fenrir2: nice abstraction of my code :)

myrdhrin: In my case I didn't care watch was being thrown, but might be handier would be if you could pass in a array of exceptions to ignore.

&lt;code&gt;retry_with_timeout(:ignoring =&#62; [Timeout::Error, SomeOtherError]) { ... } &lt;/code&gt;

There must be a way to make it sexier, say:

&lt;code&gt;3.times { try_with_timeout(5.seconds, :ignoring =&#62; SomeOtherError) { ... } }&lt;/code&gt;

(the internal timeout should specify and catch its own timeout exception as well as SomeOtherError)

I'll have a play this evening and see if I can whip that up.</description>
		<content:encoded><![CDATA[<p>Fenrir2: nice abstraction of my code :)</p>
<p>myrdhrin: In my case I didn&#8217;t care watch was being thrown, but might be handier would be if you could pass in a array of exceptions to ignore.</p>
<code>retry_with_timeout(:ignoring =&gt; [Timeout::Error, SomeOtherError]) { ... } </code>
<p>There must be a way to make it sexier, say:</p>
<code>3.times { try_with_timeout(5.seconds, :ignoring =&gt; SomeOtherError) { ... } }</code>
<p>(the internal timeout should specify and catch its own timeout exception as well as SomeOtherError)</p>
<p>I&#8217;ll have a play this evening and see if I can whip that up.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: myrdhrin</title>
		<link>http://www.sitepoint.com/blogs/2006/08/24/timing-out-and-retrying-calls-to-third-parties/#comment-47311</link>
		<dc:creator>myrdhrin</dc:creator>
		<pubDate>Wed, 23 Aug 2006 20:48:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1684#comment-47311</guid>
		<description>Fenrir2, instead of catching all the exceptions would you not be better just to catch the Timeout::Error exception?

I mean, if the code in the yield really has a problem you want to know about it...</description>
		<content:encoded><![CDATA[<p>Fenrir2, instead of catching all the exceptions would you not be better just to catch the Timeout::Error exception?</p>
<p>I mean, if the code in the yield really has a problem you want to know about it&#8230;</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Fenrir2</title>
		<link>http://www.sitepoint.com/blogs/2006/08/24/timing-out-and-retrying-calls-to-third-parties/#comment-47297</link>
		<dc:creator>Fenrir2</dc:creator>
		<pubDate>Wed, 23 Aug 2006 18:53:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1684#comment-47297</guid>
		<description>&lt;pre&gt;&lt;code&gt;def with_timeout(attempts = 3, timeout = 5)
  attempts.times do
    begin
      Timeout::timeout(timeout) do
        yield
      end
      return true
    rescue Exception
    end
  end
end&lt;/code&gt;&lt;/pre&gt;

=&#62;

&lt;pre&gt;&lt;code&gt;with_timeout do
  # ...
end&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre><code>def with_timeout(attempts = 3, timeout = 5)
  attempts.times do
    begin
      Timeout::timeout(timeout) do
        yield
      end
      return true
    rescue Exception
    end
  end
end</code></pre>
<p>=&gt;</p>
<pre><code>with_timeout do
  # ...
end</code></pre>]]></content:encoded>
	</item>
</channel>
</rss>
