[autotest] re-throw exceptions properly in urlopen_socket_timeout
urlopen_socket_timeout call handles all urllib2.URLError but only re-throw
timeout exception. Change the code to re-throw other type of exception so caller
can have a better idea of what went wrong.
BUG=none
TEST=tested with local devserver
Change-Id: I8c60f75c1fc2b8bff11a710735ce4ff8800ec15f
Reviewed-on: https://gerrit.chromium.org/gerrit/63679
Commit-Queue: Dan Shi <dshi@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
diff --git a/client/common_lib/site_utils.py b/client/common_lib/site_utils.py
index 580b6d5..37bc872 100644
--- a/client/common_lib/site_utils.py
+++ b/client/common_lib/site_utils.py
@@ -331,6 +331,8 @@
@return: The response of the urlopen call.
@raises: error.TimeoutException when a socket timeout occurs.
+ urllib2.URLError for errors that not caused by timeout.
+ urllib2.HTTPError for errors like 404 url not found.
"""
old_timeout = socket.getdefaulttimeout()
socket.setdefaulttimeout(timeout)
@@ -339,5 +341,6 @@
except urllib2.URLError as e:
if type(e.reason) is socket.timeout:
raise error.TimeoutException(str(e))
+ raise
finally:
socket.setdefaulttimeout(old_timeout)