Chromium Code Reviews| 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: |