Wraps _execute with retries. All args and kwargs are forwarded. Retries are triggered automatically when _execute throws an exception. If all retries are exhausted, _delete is invoked to cleanup the job.
(self)
| 113 | |
| 114 | # TODO(markblee): Expand the API to include create/delete/start/stop. |
| 115 | def execute(self) -> Any: |
| 116 | """Wraps _execute with retries. All args and kwargs are forwarded. |
| 117 | |
| 118 | Retries are triggered automatically when _execute throws an exception. |
| 119 | If all retries are exhausted, _delete is invoked to cleanup the job. |
| 120 | """ |
| 121 | cfg = self.config |
| 122 | |
| 123 | try: |
| 124 | return _with_retry( |
| 125 | self._execute, |
| 126 | interval=cfg.retry_interval, |
| 127 | max_tries=cfg.max_tries, |
| 128 | ) |
| 129 | except Exception: # pylint: disable=broad-except |
| 130 | # Cleanup on unexpected failure or exhausted retries. |
| 131 | self._delete() |
| 132 | raise |
| 133 | |
| 134 | |
| 135 | # TODO(markblee): Consider adding exponential backoff. |