@contract
def get_cpu_mhz(vir_connection, physical_core_mhz, previous_cpu_time,
                previous_time, current_time, current_vms,
                previous_cpu_mhz, added_vm_data):
    previous_vms = previous_cpu_time.keys()
    added_vms = get_added_vms(previous_vms, current_vms)
    removed_vms = get_removed_vms(previous_vms, current_vms)
    cpu_mhz = {}

    for uuid in removed_vms:
        del previous_cpu_time[uuid]

    for uuid, cpu_time in previous_cpu_time.items():
        current_cpu_time = get_cpu_time(vir_connection, uuid)
        if current_cpu_time < cpu_time:
            if log.isEnabledFor(logging.DEBUG):
                log.debug('VM %s: current_cpu_time < cpu_time: ' +
                          'previous CPU time %d, ' +
                          'current CPU time %d',
                          uuid, cpu_time, current_cpu_time)
                log.debug('VM %s: using previous CPU MHz %d',
                          uuid, previous_cpu_mhz[uuid])
            cpu_mhz[uuid] = previous_cpu_mhz[uuid]
        else:
            if log.isEnabledFor(logging.DEBUG):
                log.debug('VM %s: previous CPU time %d, ' +
                          'current CPU time %d, ' +
                          'previous time %.10f, ' +
                          'current time %.10f',
                          uuid, cpu_time, current_cpu_time,
                          previous_time, current_time)
            cpu_mhz[uuid] = calculate_cpu_mhz(physical_core_mhz,
                                              previous_time,
                                              current_time,
                                              cpu_time,
                                              current_cpu_time)
        previous_cpu_time[uuid] = current_cpu_time
        if log.isEnabledFor(logging.DEBUG):
            log.debug('VM %s: CPU MHz %d', uuid, cpu_mhz[uuid])

    for uuid in added_vms:
        if added_vm_data[uuid]:
            cpu_mhz[uuid] = added_vm_data[uuid][-1]
        previous_cpu_time[uuid] = get_cpu_time(vir_connection, uuid)

    return previous_cpu_time, cpu_mhz
Test requeing on recovery
dataset/ETHPy150Open beloglazov/openstack-neat/neat/locals/collector.py/get_cpu_mhz--crossover with--dataset/ETHPy150Open tweetdeck/txAMQP/src/txamqp/test/test_basic.py/BasicTests.test_recover_requeue