Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Unified Diff: build/android/pylib/utils/reraiser_thread.py

Issue 13820024: [Android] Thread names reflect the device serial number they are associated with. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove python2.7 specific features Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/base/shard.py ('k') | build/android/pylib/utils/run_tests_helper.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/reraiser_thread.py
diff --git a/build/android/pylib/utils/reraiser_thread.py b/build/android/pylib/utils/reraiser_thread.py
index bde162c112e34fb9f1c951fcfc092bd98e730507..f4fa5778c0b513b31afddaff712375ad09d92732 100644
--- a/build/android/pylib/utils/reraiser_thread.py
+++ b/build/android/pylib/utils/reraiser_thread.py
@@ -21,8 +21,16 @@ class TimeoutError(Exception):
class ReraiserThread(threading.Thread):
"""Thread class that can reraise exceptions."""
- def __init__(self, func, args=[], kwargs={}):
- super(ReraiserThread, self).__init__()
+ def __init__(self, func, args=[], kwargs={}, name=None):
+ """Initialize thread.
+
+ Args:
+ func: callable to call on a new thread.
+ args: list of positional arguments for callable, defaults to empty.
+ kwargs: dictionary of keyword arguments for callable, defaults to empty.
+ name: thread name, defaults to Thread-N.
+ """
+ super(ReraiserThread, self).__init__(name=name)
self.daemon = True
self._func = func
self._args = args
@@ -104,11 +112,10 @@ class ReraiserThreadGroup(object):
try:
self._JoinAll(watcher)
except TimeoutError:
- alive_thread_ids = (t.ident for t in self._threads if t.isAlive())
- for thread_id in alive_thread_ids:
- stack = sys._current_frames()[thread_id]
+ for thread in (t for t in self._threads if t.isAlive()):
+ stack = sys._current_frames()[thread.ident]
logging.critical('*' * 80)
- logging.critical('Stack dump for timed out ThreadId = %s', thread_id)
+ logging.critical('Stack dump for timed out thread \'%s\'', thread.name)
logging.critical('*' * 80)
for filename, lineno, name, line in traceback.extract_stack(stack):
logging.critical('File: "%s", line %d, in %s', filename, lineno, name)
« no previous file with comments | « build/android/pylib/base/shard.py ('k') | build/android/pylib/utils/run_tests_helper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698