retry.py: be more careful with getting a function name

Some python modules (xmlrpclib in this case) muck with getattr(), which
causes strange behavior with the __name__ attribute of functions.
Use a try/except block for better protection.

BUG=chromium:674679
TEST=none

Change-Id: I47c707aae5f805d53063412878fad3e0fa545cdb
Reviewed-on: https://chromium-review.googlesource.com/422547
Commit-Ready: danny chan <dchan@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: danny chan <dchan@chromium.org>
(cherry picked from commit 340975de2ccf4742d11f6a1e8f8269d346f9b077)
Reviewed-on: https://chromium-review.googlesource.com/435439
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
diff --git a/client/common_lib/cros/retry.py b/client/common_lib/cros/retry.py
index fde9d0b..22a1843 100644
--- a/client/common_lib/cros/retry.py
+++ b/client/common_lib/cros/retry.py
@@ -78,7 +78,10 @@
     @param func: the function that may time out
     @param timeout_sec: timeout length in seconds
     """
-    name = func.__name__ if hasattr(func, "__name__") else "unnamed function"
+    try:
+        name = str(func.__name__)
+    except Exception as e:
+        name = '(unavailable function name: exception: %s)' % e
     message = "sigalarm timeout (%d seconds) in %s" % (timeout_sec, name)
     return lambda signum, frame: sigalarm_wrapper(message)