CQ: catch more exceptions when looking for new pending changes.

BUG=none

Review URL: https://codereview.chromium.org/62273005

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/commit-queue@235490 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/pending_manager.py b/pending_manager.py
index be47a50..bc07d9c 100644
--- a/pending_manager.py
+++ b/pending_manager.py
@@ -13,8 +13,11 @@
   - SVN will check the committer write access.
 """
 
+import errno
 import logging
 import os
+import socket
+import ssl
 import time
 import traceback
 import urllib2
@@ -23,7 +26,6 @@
 import checkout
 import git_cl
 import patch
-import ssl
 import subprocess2
 
 import errors
@@ -193,8 +195,40 @@
     # Find new issues.
     for issue_id in new_issues:
       if str(issue_id) not in self.queue.pending_commits:
-        issue_data = self.context.rietveld.get_issue_properties(
-            issue_id, True)
+        try:
+          issue_data = self.context.rietveld.get_issue_properties(
+              issue_id, True)
+        except urllib2.HTTPError as e:
+          if e.code in (500, 502, 503):
+            # Temporary AppEngine hiccup. Just log it and continue.
+            logging.warning('%s while accessing %s. Ignoring error.' % (
+                            str(e), e.url))
+            continue
+          raise
+        except urllib2.URLError as e:
+          # Temporary AppEngine hiccup. Just log it and continue.
+          if 'timed out' in e.reason:
+            logging.warning(
+                '%s while accessing rietveld issue %s. Ignoring error.' % (
+                str(e), str(issue_id)))
+            continue
+          raise
+        except socket.error as e:
+          # Temporary AppEngine hiccup. Just log it and continue.
+          if e.errno == errno.ECONNRESET:
+            logging.warning(
+                '%s while accessing rietveld issue %s. Ignoring error.' % (
+                str(e), str(issue_id)))
+            continue
+          raise
+        except IOError as e:
+          # Temporary AppEngine hiccup. Just log it and continue.
+          if e.errno == 'socket error':
+            logging.warning(
+                '%s while accessing rietveld issue %s. Ignoring error.' % (
+                str(e), str(issue_id)))
+            continue
+          raise
         # This assumption needs to hold.
         assert issue_id == issue_data['issue']
         if issue_data['patchsets'] and issue_data['commit']: