[autotest] Divorce the devserver retry requests and sigalarm.

All dev_server requests made from the client go through a retry
wrapper that uses sigalarm to expedite unresponsive calls. Since
we cannot register our signal handlers with mod wsgi, this cl
modifies the urlopen call to manage an internal socket timeout
instead. In order to continue retrying on other URLErrors, the
urlopen wrapper in site_utils converts socket timeouts to
TimeoutExceptions.

TEST=
1. Added a bad devserver, tried to run_suite on a build that hashed
   to said devserver with and without this change and verified that
   it only worked in the latter case.
2. Sigalarm still fires when devserver's resolve is called outside wsgi,
   and urlopen has a larger timeout.
3. Non TimeoutException URLErrors retry.
4. dev_server_unittest pass.
BUG=chromium:246209

Change-Id: Iec9ef39982f4c8b92e260cf27bf454e624bccfa9
Reviewed-on: https://gerrit.chromium.org/gerrit/58659
Tested-by: Prashanth Balasubramanian <beeps@chromium.org>
Reviewed-by: Alex Miller <milleral@chromium.org>
Commit-Queue: Prashanth Balasubramanian <beeps@chromium.org>
diff --git a/client/common_lib/cros/retry.py b/client/common_lib/cros/retry.py
index d528440..ae2e425 100644
--- a/client/common_lib/cros/retry.py
+++ b/client/common_lib/cros/retry.py
@@ -8,18 +8,11 @@
 from autotest_lib.frontend.afe.json_rpc import proxy
 
 
-class TimeoutException(Exception):
-    """
-    Exception to be raised for when alarm is triggered.
-    """
-    pass
-
-
 def handler(signum, frame):
     """
     Register a handler for the timeout.
     """
-    raise TimeoutException('Call is timed out.')
+    raise error.TimeoutException('Call is timed out.')
 
 
 def install_sigalarm_handler(new_handler):
@@ -97,7 +90,7 @@
     try:
         default_result = func(*args, **kwargs)
         return False, default_result
-    except TimeoutException:
+    except error.TimeoutException:
         return True, default_result
     finally:
         # If we installed a sigalarm handler, cancel it since our function
@@ -180,7 +173,7 @@
 
             # The call must have timed out or raised ExceptionToCheck.
             if not exc_info:
-                raise TimeoutException('Call is timed out.')
+                raise error.TimeoutException('Call is timed out.')
             # Raise the cached exception with original backtrace.
             raise exc_info[0], exc_info[1], exc_info[2]