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

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

Issue 76233005: [Android] Refactor and reuse reraiser_thread thread stack dumping utility. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PrintThreadStack -> LogThreadStack Created 7 years, 1 month 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 | « no previous file | build/android/test_runner.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 f4fa5778c0b513b31afddaff712375ad09d92732..d4ba781a32d856def495f44499ce123cd94d9fc0 100644
--- a/build/android/pylib/utils/reraiser_thread.py
+++ b/build/android/pylib/utils/reraiser_thread.py
@@ -18,6 +18,23 @@ class TimeoutError(Exception):
pass
+def LogThreadStack(thread):
+ """Log the stack for the given thread.
+
+ Args:
+ thread: a threading.Thread instance.
+ """
+ stack = sys._current_frames()[thread.ident]
+ logging.critical('*' * 80)
+ logging.critical('Stack dump for 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)
+ if line:
+ logging.critical(' %s', line.strip())
+ logging.critical('*' * 80)
+
+
class ReraiserThread(threading.Thread):
"""Thread class that can reraise exceptions."""
@@ -113,13 +130,5 @@ class ReraiserThreadGroup(object):
self._JoinAll(watcher)
except TimeoutError:
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 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)
- if line:
- logging.critical(' %s', line.strip())
- logging.critical('*' * 80)
+ LogThreadStack(thread)
raise
« no previous file with comments | « no previous file | build/android/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698