def _wait_for_job_finished(job): """ This function waits for asynchronous job to be finished. :param job: Instance of ``LMI_SoftwareJob``. :type job: :py:class:`lmi.shell.LMIInstance` """ if not isinstance(job, LMIInstance): raise TypeError("job must be an LMIInstance") LOG().debug('Waiting for a job "%s" to finish.', job.InstanceID) sleep_time = INITIAL_SLEEP_TIME connection_problem_count = 0 while not LMIJob.lmi_is_job_finished(job): # Sleep, a bit longer in every iteration time.sleep(sleep_time) if sleep_time < LMIMethod._POLLING_ADAPT_MAX_WAITING_TIME: sleep_time = min(sleep_time * SLEEP_TIME_MULTIPLIER, LMIMethod._POLLING_ADAPT_MAX_WAITING_TIME) try: (refreshed, _, errorstr) = job.refresh() except wbem.CIMError as err: if (err.args[0] == 0 and err.args[1].lower().startswith('socket error')): if connection_problem_count >= MAX_CONNECTION_PROBLEM_COUNT: raise LOG().warn("Connection problem: %s", err.args[1]) if connection_problem_count == 0: sleep_time = CONNECTION_PROBLEM_SLEEP_TIME connection_problem_count += 1 else: raise if not refreshed: raise LMIExceptions.LMISynchroMethodCallError(errorstr)
def _wait_for_job_finished(job): """ This function waits for asynchronous job to be finished. :param job: Instance of ``LMI_SoftwareJob``. :type job: :py:class:`lmi.shell.LMIInstance` """ if not isinstance(job, LMIInstance): raise TypeError("job must be an LMIInstance") LOG().debug('Waiting for a job "%s" to finish.', job.InstanceID) sleep_time = INITIAL_SLEEP_TIME connection_problem_count = 0 while not LMIJob.lmi_is_job_finished(job): # Sleep, a bit longer in every iteration time.sleep(sleep_time) if sleep_time < LMIMethod._POLLING_ADAPT_MAX_WAITING_TIME: sleep_time = min(sleep_time * SLEEP_TIME_MULTIPLIER, LMIMethod._POLLING_ADAPT_MAX_WAITING_TIME) try: (refreshed, _, errorstr) = job.refresh() except pywbem.CIMError as err: if ( err.args[0] == 0 and err.args[1].lower().startswith('socket error')): if connection_problem_count >= MAX_CONNECTION_PROBLEM_COUNT: raise LOG().warn("Connection problem: %s", err.args[1]) if connection_problem_count == 0: sleep_time = CONNECTION_PROBLEM_SLEEP_TIME connection_problem_count += 1 else: raise if not refreshed: raise LMIExceptions.LMISynchroMethodCallError(errorstr)
def _wait_for_job_finished(job): """ This function waits for asynchronous job to be finished. :param job: Instance of ``LMI_SoftwareJob``. :type job: :py:class:`lmi.shell.LMIInstance` """ if not isinstance(job, LMIInstance): raise TypeError("job must be an LMIInstance") LOG().debug('waiting for a job "%s" to finish', job.InstanceId) sleep_time = 0.5 while not LMIJob.lmi_is_job_finished(job): # Sleep, a bit longer in every iteration time.sleep(sleep_time) if sleep_time < LMIMethod._POLLING_ADAPT_MAX_WAITING_TIME: sleep_time *= 1.5 (refreshed, _, errorstr) = job.refresh() if not refreshed: raise LMIExceptions.LMISynchroMethodCallError(errorstr)
def _wait_for_job_finished(job): """ This function waits for asynchronous job to be finished. :param job: Instance of ``LMI_SoftwareJob``. :type job: :py:class:`lmi.shell.LMIInstance` """ if not isinstance(job, LMIInstance): raise TypeError("job must be an LMIInstance") LOG().debug('waiting for a job "%s" to finish', job.InstanceId) sleep_time = 0.5 while not LMIJob.lmi_is_job_finished(job): # Sleep, a bit longer in every iteration time.sleep(sleep_time) if sleep_time < LMIMethod._POLLING_ADAPT_MAX_WAITING_TIME: sleep_time *= 1.5 (refreshed, _, errorstr) = job.refresh() if not refreshed: raise LMIExceptions.LMISynchroMethodCallError(errorstr)