• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python waiting.wait函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中waiting.wait函数的典型用法代码示例。如果您正苦于以下问题:Python wait函数的具体用法?Python wait怎么用?Python wait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wait函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _prepare_neutron_server_and_env

    def _prepare_neutron_server_and_env(self, net_count):
        """Prepares neutron service network count on dhcp agent
            and prepares env.

        :param net_count: how many networks musth dhcp agent handle
        """
        def _check_neutron_restart():
            try:
                self.os_conn.list_networks()['networks']
            except Exception as e:
                logger.debug(e)
                return False
            return True

        all_controllers = self.env.get_nodes_by_role('controller')
        for controller in all_controllers:
            with controller.ssh() as remote:
                res = self._apply_new_neutron_param_value(remote, net_count)
                error_msg = (
                    'Neutron service restart with new value failed, '
                    'exit code {exit_code},'
                    'stdout {stdout}, stderr {stderr}').format(**res)
                assert 0 == res['exit_code'], error_msg

        wait_msg = "Waiting for neutron is up"
        wait(
            lambda: _check_neutron_restart(),
            timeout_seconds=60 * 3,
            sleep_seconds=(1, 60, 5),
            waiting_for=wait_msg)

        self._prepare_openstack_state()
开发者ID:AlexGromov,项目名称:mos-integration-tests,代码行数:32,代码来源:test_ban_dhcp_agent.py


示例2: clear_l3_agent

    def clear_l3_agent(self, _ip, router_name, node, wait_for_alive=False):
        """Clear L3 agent ban and wait until router moved to this node

        Clear previously banned L3 agent on node wait until router moved
        to this node

        :param _ip: ip of server to to execute clear command
        :param router_name: name of router to wait until it move to node
        :param node: name of node to clear
        :param wait_for_alive:
        """
        router = self.os_conn.neutron.list_routers(
            name=router_name)['routers'][0]
        with self.env.get_ssh_to_node(_ip) as remote:
            remote.execute(
                "pcs resource clear p_neutron-l3-agent {0}".format(node))

        logger.info("Clear L3 agent on node {0}".format(node))

        # wait for l3 agent alive
        if wait_for_alive:
            wait(
                lambda: self.os_conn.get_l3_for_router(
                    router['id'])['agents'][0]['alive'] is True,
                timeout_seconds=60 * 3, waiting_for="L3 agent is alive",
                sleep_seconds=(1, 60)
            )
开发者ID:AlexGromov,项目名称:mos-integration-tests,代码行数:27,代码来源:test_l3_agent.py


示例3: test_predicate_sleeps_coelesce

def test_predicate_sleeps_coelesce(timeline, do_sleep):
    timeline.predicate_sleep = 0.5 if do_sleep else 0
    sleep_seconds = 2
    expected_sleep = sleep_seconds - timeline.predicate_sleep
    timeline.satisfy_after_time = 10
    waiting.wait(timeline.predicate, sleep_seconds=2)
    assert timeline.sleeps_performed == [expected_sleep for i in range(5)]
开发者ID:simudream,项目名称:waiting,代码行数:7,代码来源:test_predicate_sleeps.py


示例4: run_in_split

def run_in_split(self, cmd, resize, background):
    tree = self.i3.get_tree()
    focused = tree.find_focused()
    ws = focused.workspace_of()
    ws.focus()
    ws.split_vertical()
    proc = subproc.popen(cmd, async_=True)
    def focus_changed():
        new_focused = self.i3.get_tree().find_focused()
        return (new_focused != focused and new_focused != ws
                and new_focused.is_window)

    waiting.wait(
            focus_changed,
            timeout_seconds=2,
            sleep_seconds=0.1)
    new = self.i3.get_tree().find_focused()
    assert new != focused
    if resize:
        new.resize_set_ppt(height=resize)
    if background:
        focused.focus()
    status = proc.wait()
    print(status)
    sys.exit(status)
    return status
开发者ID:sergei-dyshel,项目名称:qyron-config,代码行数:26,代码来源:cli.py


示例5: __enter__

 def __enter__(self):
     try:
         waiting.wait(self._try_acquire)
         return self
     except:
         self.__exit__(*sys.exc_info())
         raise
开发者ID:omergertel,项目名称:chords,代码行数:7,代码来源:chord.py


示例6: reset_computes

    def reset_computes(self, hostnames, env_name):

        def get_hipervisors():
            return [x for x in self.os_conn.nova.hypervisors.list()
                    if x.hypervisor_hostname in hostnames]

        node_states = defaultdict(list)

        def is_nodes_started():
            for hypervisor in get_hipervisors():
                state = hypervisor.state
                prev_states = node_states[hypervisor.hypervisor_hostname]
                if len(prev_states) == 0 or state != prev_states[-1]:
                    prev_states.append(state)

            return all(x[-2:] == ['down', 'up'] for x in node_states.values())

        logger.info('Resetting computes {}'.format(hostnames))
        for hostname in hostnames:
            node = self.env.find_node_by_fqdn(hostname)
            devops_node = DevopsClient.get_node_by_mac(env_name=env_name,
                                                       mac=node.data['mac'])
            devops_node.reset()

        wait(is_nodes_started, timeout_seconds=10 * 60)
开发者ID:AlexGromov,项目名称:mos-integration-tests,代码行数:25,代码来源:test_dvr.py


示例7: wait_for_status

 def wait_for_status(self, status, timeout=EVENT_TIMEOUT):
     """Wait status value after transit statuses."""
     self.wait_for_presence()
     with self.cell('status') as cell:
         wait(lambda: cell.value not in self.transit_statuses,
              timeout_seconds=EVENT_TIMEOUT, sleep_seconds=0.1)
         assert cell.value == status
开发者ID:sergeychipiga,项目名称:horizon_autotests,代码行数:7,代码来源:table.py


示例8: check_vm_is_accessible_with_ssh

    def check_vm_is_accessible_with_ssh(self, vm_ip, username=None,
                                        password=None, pkeys=None):
        """Check that instance is accessible with ssh via floating_ip.

        :param vm_ip: floating_ip of instance
        :param username: username to login to instance
        :param password: password to connect to instance
        :param pkeys: private keys to connect to instance
        """
        error_msg = 'Instance with ip {0} is not accessible with ssh.'\
            .format(vm_ip)

        def is_accessible():
            try:
                with self.env.get_ssh_to_vm(
                        vm_ip, username, password, pkeys) as vm_remote:
                    vm_remote.execute("date")
                    return True
            except ssh_exception.SSHException:
                return False
            except ssh_exception.NoValidConnectionsError:
                return False

        wait(is_accessible,
             sleep_seconds=10, timeout_seconds=60,
             waiting_for=error_msg)
开发者ID:AlexGromov,项目名称:mos-integration-tests,代码行数:26,代码来源:base.py


示例9: check_vm_is_available

    def check_vm_is_available(self, vm,
                              username=None, password=None, pkeys=None):
        """Check that instance is available for connect from controller.

        :param vm: instance to ping from it compute node
        :param username: username to login to instance
        :param password: password to connect to instance
        :param pkeys: private keys to connect to instance
        """
        vm = self.os_conn.get_instance_detail(vm)
        srv_host = self.env.find_node_by_fqdn(
            self.os_conn.get_srv_hypervisor_name(vm)).data['ip']

        vm_ip = self.os_conn.get_nova_instance_ips(vm)['floating']

        with self.env.get_ssh_to_node(srv_host) as remote:
            cmd = "ping -c1 {0}".format(vm_ip)

            waiting_for_msg = (
                'Waiting for instance with ip {0} has '
                'connectivity from node with ip {1}.').format(vm_ip, srv_host)

            wait(lambda: remote.execute(cmd)['exit_code'] == 0,
                 sleep_seconds=10, timeout_seconds=3 * 10,
                 waiting_for=waiting_for_msg)
        return self.check_vm_is_accessible_with_ssh(
            vm_ip, username=username, password=password, pkeys=pkeys)
开发者ID:AlexGromov,项目名称:mos-integration-tests,代码行数:27,代码来源:base.py


示例10: assign_floating_ip

    def assign_floating_ip(self, srv, use_neutron=False):
        if use_neutron:
            #   Find external net id for tenant
            nets = self.neutron.list_networks()['networks']
            err_msg = "Active external network not found in nets:{}"
            ext_net_ids = [
                net['id'] for net in nets
                if net['router:external'] and net['status'] == "ACTIVE"]
            assert ext_net_ids, err_msg.format(nets)
            net_id = ext_net_ids[0]
            #   Find instance port
            ports = self.neutron.list_ports(device_id=srv.id)['ports']
            err_msg = "Not found active ports for instance:{}"
            assert ports, err_msg.format(srv.id)
            port = ports[0]
            #   Create floating IP
            body = {'floatingip': {'floating_network_id': net_id,
                                   'port_id': port['id']}}
            flip = self.neutron.create_floatingip(body)
            #   Wait active state for port
            port_id = flip['floatingip']['port_id']
            state = lambda: self.neutron.show_port(port_id)['port']['status']
            wait(lambda: state() == "ACTIVE")
            return flip['floatingip']

        fl_ips_pool = self.nova.floating_ip_pools.list()
        if fl_ips_pool:
            floating_ip = self.nova.floating_ips.create(
                pool=fl_ips_pool[0].name)
            self.nova.servers.add_floating_ip(srv, floating_ip)
            return floating_ip
开发者ID:AlexGromov,项目名称:mos-integration-tests,代码行数:31,代码来源:os_actions.py


示例11: go_to

    def go_to(self, item_names):
        """Go to page via navigate menu.

        Arguments:
            - item_names: list of items of navigate menu.
        """
        container = self
        last_name = item_names[-1]

        for item_name in item_names:
            item = ui.UI(
                By.XPATH, './li/a[contains(., "{}")]'.format(item_name))
            item.container = container

            if item_name == last_name:
                item.click()
                break

            sub_menu = ui.Block(
                By.XPATH,
                ('./li/ul[contains(@class, "collapse") and preceding-sibling'
                 '::a[contains(., "{}")]]'.format(item_name)))
            sub_menu.container = container

            if not _is_expanded(sub_menu):
                item.click()
                wait(lambda: _is_expanded(sub_menu),
                     timeout_seconds=10, sleep_seconds=0.1)

            container = sub_menu
开发者ID:sergeychipiga,项目名称:horizon_autotests,代码行数:30,代码来源:navigate_menu.py


示例12: test_set_image_disk_and_ram_size

    def test_set_image_disk_and_ram_size(self, horizon, create_image):
        """Verify that image limits has influence to flavor choice."""
        ram_size = 1024
        disk_size = 4

        image_name = next(generate_ids('image', length=20))
        create_image(image_name, min_disk=disk_size, min_ram=ram_size)

        with horizon.page_images as page:
            page.table_images.row(
                name=image_name).dropdown_menu.item_default.click()

            with page.form_launch_instance as form:
                form.item_flavor.click()
                wait(lambda: form.tab_flavor.table_available_flavors.rows,
                     timeout_seconds=30, sleep_seconds=0.1)

                for row in form.tab_flavor.table_available_flavors.rows:

                    ram_cell = row.cell('ram')
                    if get_size(ram_cell.value, to='mb') < ram_size:
                        assert ram_cell.label_alert.is_present
                    else:
                        assert not ram_cell.label_alert.is_present

                    disk_cell = row.cell('root_disk')
                    if get_size(disk_cell.value, to='gb') < disk_size:
                        assert disk_cell.label_alert.is_present
                    else:
                        assert not disk_cell.label_alert.is_present
                form.cancel()
开发者ID:sergeychipiga,项目名称:horizon_autotests,代码行数:31,代码来源:test_images.py


示例13: test_nexted_stop_iteration_preserve_traceback

def test_nexted_stop_iteration_preserve_traceback():
    expected_exception = StopIteration('foo')

    def predicate():
        raise expected_exception

    with pytest.raises(StopIteration) as ex:
        waiting.wait(predicate, timeout_seconds=0)
    assert '        raise expected_exception' in ex.traceback[-1].statement.lines
开发者ID:vmalloc,项目名称:waiting,代码行数:9,代码来源:test_waiting.py


示例14: test_nexted_stop_iteration_preserve_exception

def test_nexted_stop_iteration_preserve_exception():
    expected_exception = StopIteration('foo')

    def predicate():
        raise expected_exception

    with pytest.raises(StopIteration) as ex:
        waiting.wait(predicate, timeout_seconds=0)
    assert ex.value is expected_exception
开发者ID:vmalloc,项目名称:waiting,代码行数:9,代码来源:test_waiting.py


示例15: test_wait_any_satisfied_on_start

def test_wait_any_satisfied_on_start(predicates, forge, timeline):
    for index, p in enumerate(predicates):
        works = (index == 2)
        p().and_return(works)
        if works:
            break
    forge.replay()
    waiting.wait(waiting.ANY(predicates))
    assert timeline.virtual_time == 0
开发者ID:vmalloc,项目名称:waiting,代码行数:9,代码来源:test_waiting.py


示例16: test__wait_any_satisfied_on_start

 def test__wait_any_satisfied_on_start(self):
     for index, p in enumerate(self.predicates):
         works = (index == 2)
         p().and_return(works)
         if works:
             break
     self.forge.replay()
     waiting.wait(waiting.ANY(self.predicates))
     self.assertEquals(self.virtual_time, 0)
开发者ID:Khrol,项目名称:waiting,代码行数:9,代码来源:test__waiting.py


示例17: warm_start_nodes

 def warm_start_nodes(self, devops_nodes):
     for node in devops_nodes:
         logger.info('Starting node {}'.format(node.name))
         node.create()
     wait(self.check_nodes_get_online_state, timeout_seconds=10 * 60)
     logger.info('wait until the nodes get online state')
     for node in self.get_all_nodes():
         logger.info('online state of node {0} now is {1}'
                     .format(node.data['name'], node.data['online']))
开发者ID:AlexGromov,项目名称:mos-integration-tests,代码行数:9,代码来源:fuel_client.py


示例18: wait_for_absence

 def wait_for_absence(self, timeout=None):
     """Wait for ui element absence."""
     timeout = timeout or self.timeout
     try:
         wait(lambda: not self.is_present,
              timeout_seconds=timeout, sleep_seconds=0.1)
     except TimeoutExpired:
         raise Exception(
             "{!r} is still present after {} sec".format(self, timeout))
开发者ID:sergeychipiga,项目名称:pom,代码行数:9,代码来源:base.py


示例19: test__wait_all

 def test__wait_all(self):
     for iteration in range(len(self.predicates) * 2, 0, -1):
         iteration -= 1
         for index, p in reversed(list(enumerate(self.predicates))):
             if index > iteration:
                 continue
             p().and_return(index == iteration)
     self.forge.replay()
     waiting.wait(waiting.ALL(self.predicates))
     self.assertEquals(self.virtual_time, len(self.predicates) * 2 - 1)
开发者ID:Khrol,项目名称:waiting,代码行数:10,代码来源:test__waiting.py


示例20: test_wait_all

def test_wait_all(predicates, forge, timeline):
    for iteration in range(len(predicates) * 2, 0, -1):
        iteration -= 1
        for index, p in reversed(list(enumerate(predicates))):
            if index > iteration:
                continue
            p().and_return(index == iteration)
    forge.replay()
    waiting.wait(waiting.ALL(predicates))
    assert timeline.virtual_time == ((len(predicates) * 2) - 1)
开发者ID:vmalloc,项目名称:waiting,代码行数:10,代码来源:test_waiting.py



注:本文中的waiting.wait函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python waitress.serve函数代码示例发布时间:2022-05-26
下一篇:
Python wait_for.wait_for函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap