Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import traceback | 5 import traceback |
| 6 | 6 |
| 7 | 7 |
| 8 class Execution(object): | 8 class Execution(object): |
| 9 """Object tracking the execution of a Quest. | 9 """Object tracking the execution of a Quest. |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 @property | 58 @property |
| 59 def result_arguments(self): | 59 def result_arguments(self): |
| 60 """A dict of information passed on to the next Execution. | 60 """A dict of information passed on to the next Execution. |
| 61 | 61 |
| 62 For example, the Build Execution passes the isolate hash to the Test | 62 For example, the Build Execution passes the isolate hash to the Test |
| 63 Execution. | 63 Execution. |
| 64 """ | 64 """ |
| 65 assert self.completed | 65 assert self.completed |
| 66 return self._result_arguments | 66 return self._result_arguments |
| 67 | 67 |
| 68 def AsDict(self): | |
| 69 d = { | |
| 70 'result_arguments': self.result_arguments if self.completed else {}, | |
| 71 'result_values': self.result_values if self.completed else [] | |
|
dtu
2017/08/22 16:46:19
nit: else null
shatch
2017/08/22 17:01:20
Done.
| |
| 72 } | |
| 73 d.update(self._AsDict()) | |
| 74 return d | |
| 75 | |
| 76 def _AsDict(self): | |
| 77 raise NotImplementedError() | |
| 78 | |
| 68 def Poll(self): | 79 def Poll(self): |
| 69 """Update the Execution status.""" | 80 """Update the Execution status.""" |
| 70 assert not self.completed | 81 assert not self.completed |
| 71 | 82 |
| 72 try: | 83 try: |
| 73 self._Poll() | 84 self._Poll() |
| 74 except StandardError: | 85 except StandardError: |
| 75 # StandardError most likely indicates a bug in the code. | 86 # StandardError most likely indicates a bug in the code. |
| 76 # We should fail fast to aid debugging. | 87 # We should fail fast to aid debugging. |
| 77 raise | 88 raise |
| 78 except Exception: # pylint: disable=broad-except | 89 except Exception: # pylint: disable=broad-except |
| 79 # We allow broad exception handling here, because we log the exception and | 90 # We allow broad exception handling here, because we log the exception and |
| 80 # display it in the UI. | 91 # display it in the UI. |
| 81 self._completed = True | 92 self._completed = True |
| 82 self._failed = True | 93 self._failed = True |
| 83 self._result_values = (traceback.format_exc(),) | 94 self._result_values = (traceback.format_exc(),) |
| 84 | 95 |
| 85 | 96 |
| 86 def _Poll(self): | 97 def _Poll(self): |
| 87 raise NotImplementedError() | 98 raise NotImplementedError() |
| 88 | 99 |
| 89 def _Complete(self, result_values=None, result_arguments=None): | 100 def _Complete(self, result_values=None, result_arguments=None): |
| 90 self._completed = True | 101 self._completed = True |
| 91 self._failed = False | 102 self._failed = False |
| 92 self._result_values = result_values or (None,) | 103 self._result_values = result_values or (None,) |
| 93 self._result_arguments = result_arguments or {} | 104 self._result_arguments = result_arguments or {} |
| OLD | NEW |