openstack oslo_services loopingcalls

Могу ли я добиться следующей функциональности, используя "FixedIntervalWithTimeoutLoopingCall" вместо "FixedIntervalLoopingCall":->

def initialize_connection(self, volume, connector, initiator_data=None):
    lun_name = self._get_va_lun_name(volume.id)
    target = {'target_name': ''}

    def _inner(start_time):
        current_time = time.time()
        lun_list = self._get_vrts_lun_list()
        for lun in lun_list['output']['output']['luns']:
            if lun['lun_name'] == lun_name:
                target['target_name'] = lun['target_name']
                raise loopingcall.LoopingCallDone()

        if current_time - start_time > self.LUN_FOUND_INTERVAL:
            message = (_('ACCESSIscsiDriver initialize_connection '
                         'failed for %s as no target was found')
                       % volume.id)
            LOG.error(message)
            raise exception.VolumeBackendAPIException(message=message)

    timer = loopingcall.FixedIntervalLoopingCall(_inner, time.time())
    timer.start(interval=5).wait()

0 ответов

Другие вопросы по тегам