| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 the V8 project authors. All rights reserved. |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 wait_plan: A list of waiting delays between retries in seconds. The | 311 wait_plan: A list of waiting delays between retries in seconds. The |
| 312 maximum number of retries is len(wait_plan). | 312 maximum number of retries is len(wait_plan). |
| 313 """ | 313 """ |
| 314 retry_on = retry_on or (lambda x: False) | 314 retry_on = retry_on or (lambda x: False) |
| 315 wait_plan = list(wait_plan or []) | 315 wait_plan = list(wait_plan or []) |
| 316 wait_plan.reverse() | 316 wait_plan.reverse() |
| 317 while True: | 317 while True: |
| 318 got_exception = False | 318 got_exception = False |
| 319 try: | 319 try: |
| 320 result = cb() | 320 result = cb() |
| 321 except NoRetryException, e: | 321 except NoRetryException as e: |
| 322 raise e | 322 raise e |
| 323 except Exception: | 323 except Exception as e: |
| 324 got_exception = True | 324 got_exception = e |
| 325 if got_exception or retry_on(result): | 325 if got_exception or retry_on(result): |
| 326 if not wait_plan: # pragma: no cover | 326 if not wait_plan: # pragma: no cover |
| 327 raise Exception("Retried too often. Giving up.") | 327 raise Exception("Retried too often. Giving up. Reason: %s" % |
| 328 str(got_exception)) |
| 328 wait_time = wait_plan.pop() | 329 wait_time = wait_plan.pop() |
| 329 print "Waiting for %f seconds." % wait_time | 330 print "Waiting for %f seconds." % wait_time |
| 330 self._side_effect_handler.Sleep(wait_time) | 331 self._side_effect_handler.Sleep(wait_time) |
| 331 print "Retrying..." | 332 print "Retrying..." |
| 332 else: | 333 else: |
| 333 return result | 334 return result |
| 334 | 335 |
| 335 def ReadLine(self, default=None): | 336 def ReadLine(self, default=None): |
| 336 # Don't prompt in forced mode. | 337 # Don't prompt in forced mode. |
| 337 if self._options.force_readline_defaults and default is not None: | 338 if self._options.force_readline_defaults and default is not None: |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 for (number, step_class) in enumerate(step_classes): | 653 for (number, step_class) in enumerate(step_classes): |
| 653 steps.append(MakeStep(step_class, number, self._state, self._config, | 654 steps.append(MakeStep(step_class, number, self._state, self._config, |
| 654 options, self._side_effect_handler)) | 655 options, self._side_effect_handler)) |
| 655 for step in steps[options.step:]: | 656 for step in steps[options.step:]: |
| 656 if step.Run(): | 657 if step.Run(): |
| 657 return 1 | 658 return 1 |
| 658 return 0 | 659 return 0 |
| 659 | 660 |
| 660 def Run(self, args=None): | 661 def Run(self, args=None): |
| 661 return self.RunSteps(self._Steps(), args) | 662 return self.RunSteps(self._Steps(), args) |
| OLD | NEW |