<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -86,15 +86,22 @@ module Politics
         # If another process got there first, this is a noop.
         # We add an expiry so that the master token will constantly
         # need to be refreshed (in case the current leader dies).
-        nominate
-
         time = 0
-        if leader?
-          Politics::log.info { &quot;#{worker_name} elected leader at #{Time.now}&quot; }
-          # If we are the master worker, do the work.
-          time = time_for do
-            result = block.call(*args)
+        begin
+          nominate
+
+          if leader?
+            Politics::log.info { &quot;#{worker_name} elected leader at #{Time.now}&quot; }
+            # If we are the master worker, do the work.
+            time = time_for do
+              result = block.call(*args)
+            end
           end
+        rescue MemCache::MemCacheError =&gt; me
+          Politics::log.error(&quot;Error from memcached, pausing until the next iteration...&quot;)
+          Politics::log.error(me.message)
+          Politics::log.error(me.backtrace.join(&quot;\n&quot;))
+          self.memcache_client.reset
         end
         
         pause_until_expiry(time)</diff>
      <filename>lib/politics/token_worker.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>170614baca5a8d2483829225fbd1ee6445d85a16</id>
    </parent>
  </parents>
  <author>
    <name>Mike Perham</name>
    <email>mperham@gmail.com</email>
  </author>
  <url>http://github.com/mperham/politics/commit/38a432af969d986dd896df7c2844e904394a68b5</url>
  <id>38a432af969d986dd896df7c2844e904394a68b5</id>
  <committed-date>2009-02-04T08:58:25-08:00</committed-date>
  <authored-date>2009-02-04T08:58:25-08:00</authored-date>
  <message>Catch and try to handle memcached failures gracefully.</message>
  <tree>497a31662f38a4d1f3452d0b219d866ae5e415cb</tree>
  <committer>
    <name>Mike Perham</name>
    <email>mperham@gmail.com</email>
  </committer>
</commit>
