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

Unified Diff: devil/devil/android/logcat_monitor.py

Issue 1635903003: [Devil] Add timeout to logcat record thread join. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Fix syntax error. Created 4 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: devil/devil/android/logcat_monitor.py
diff --git a/devil/devil/android/logcat_monitor.py b/devil/devil/android/logcat_monitor.py
index 497a6bf92c097286b7b49493defe4e031019acd3..a3d51e8f33e13f2f05009d9e93b4f072eda648a2 100644
--- a/devil/devil/android/logcat_monitor.py
+++ b/devil/devil/android/logcat_monitor.py
@@ -20,6 +20,7 @@ from devil.utils import reraiser_thread
class LogcatMonitor(object):
+ _LOGCAT_GENERATOR_TIMEOUT = 5.0
_WAIT_TIME = 0.2
_THREADTIME_RE_FORMAT = (
r'(?P<date>\S*) +(?P<time>\S*) +(?P<proc_id>%s) +(?P<thread_id>%s) +'
@@ -154,13 +155,23 @@ class LogcatMonitor(object):
def record_to_file():
# Write the log with line buffering so the consumer sees each individual
# line.
+ logcat_generator = self._adb.Logcat(filter_specs=self._filter_specs,
+ logcat_format='threadtime')
+ @decorators.WithExplicitTimeoutAndRetries(
jbudorick 2016/01/26 23:13:19 This decorator is here to check a condition (wheth
jbudorick 2016/01/26 23:32:37 As for the slowness part, we could potentially add
+ self._LOGCAT_GENERATOR_TIMEOUT, 0)
+ def logcat_next():
+ logcat_generator.next()
+
with open(self._record_file.name, 'a', 1) as f:
- for data in self._adb.Logcat(filter_specs=self._filter_specs,
- logcat_format='threadtime'):
+ while True:
+ try:
+ data = logcat_next()
+ f.write(data + '\n')
+ except device_errors.CommandTimeoutError:
+ pass
if self._stop_recording_event.isSet():
f.flush()
return
- f.write(data + '\n')
self._stop_recording_event.clear()
if not self._record_thread:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698