Exemple #1
0
 def __init__(self, manager, **manager_options):
     super(StatefulManagerProxy, self).__init__(manager)
     min_polling_interval = float(manager_options.get("min_polling_interval", DEFAULT_MIN_POLLING_INTERVAL))
     preprocess_retry_action_kwds = filter_destination_params(manager_options, "preprocess_action_")
     postprocess_retry_action_kwds = filter_destination_params(manager_options, "postprocess_action_")
     self.__preprocess_action_executor = RetryActionExecutor(**preprocess_retry_action_kwds)
     self.__postprocess_action_executor = RetryActionExecutor(**postprocess_retry_action_kwds)
     self.min_polling_interval = datetime.timedelta(0, min_polling_interval)
     self.active_jobs = ActiveJobs.from_manager(manager)
     self.__state_change_callback = self._default_status_change_callback
     self.__monitor = None
def test_exception_passthrough():
    action_tracker = ActionTracker(fail_count=1)
    exception_raised = False
    try:
        RetryActionExecutor().execute(action_tracker.execute)
    except Exception:
        exception_raised = True
    assert action_tracker.count == 1
    assert exception_raised
def test_third_execution_fine():
    action_tracker = ActionTracker(fail_count=2)
    exception_raised = False
    try:
        RetryActionExecutor(max_retries=2,
                            interval_start=.01,
                            interval_step=.01).execute(action_tracker.execute)
    except Exception:
        exception_raised = True
    assert action_tracker.count == 3, action_tracker.count
    assert not exception_raised
Exemple #4
0
 def __init__(self,
              username,
              hostname,
              password=None,
              private_key=None,
              port=22,
              timeout=60,
              **kwargs):
     self.username = username
     self.hostname = hostname
     self.password = password
     self.private_key = private_key
     self.port = int(port) if port else port
     self.timeout = int(timeout) if timeout else timeout
     self.ssh = None
     self.retry_action_executor = RetryActionExecutor(max_retries=100,
                                                      interval_max=300)
     self.connect()
def test_retry_defaults():
    action_tracker = ActionTracker()
    assert RetryActionExecutor().execute(action_tracker.execute) == 42
    assert action_tracker.count == 1