code: def is_task_running(self, task, connection_failure_control=None):
          
          if 'uri' in task:
              try:
                  task = self.get(task)
                  if connection_failure_control:
                      # Updates last success
                      connection_failure_control['last_success'] = self.get_current_seconds()
                  if 'taskState' in task and task['taskState'] in TASK_PENDING_STATES:
                      return True
  
              except Exception as error:
                  logger.error('; '.join(str(e) for e in error.args) + ' when waiting for the task: ' + str(task))
  
                  if not connection_failure_control:
                      raise error
  
                  if hasattr(error, 'errno') and error.errno in self.CONNECTION_FAILURE_ERROR_NUMBERS:
                      last_success = connection_failure_control['last_success']
                      if last_success + self.CONNECTION_FAILURE_TIMEOUT < self.get_current_seconds():
                          # Timeout reached
                          raise error
                      else:
                          # Return task is running when network instability occurs
                          return True
                  else:
                      raise error
  
          return False
docs: Check if a task is running according to: TASK_PENDING_STATES ['New', 'Starting',
          'Pending', 'Running', 'Suspended', 'Stopping']
  
          Args:
              task (dict): OneView Task resource.
              connection_failure_control (dict):
                  A dictionary instance that contains last_success for error tolerance control.
  
          Examples:
  
              >>> connection_failure_control = dict(last_success=int(time.time()))
              >>> while self.is_task_running(task, connection_failure_control):
              >>>     pass
  
          Returns:
              True when in TASK_PENDING_STATES; False when not.