当前位置: 首页>>代码示例>>Python>>正文


Python pykka.get_all函数代码示例

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


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

示例1: test_get_all_raises_timeout_if_not_all_futures_are_available

def test_get_all_raises_timeout_if_not_all_futures_are_available(futures):
    futures[0].set(0)
    futures[1].set(1)
    # futures[2] is unset

    with pytest.raises(Timeout):
        get_all(futures, timeout=0)
开发者ID:jodal,项目名称:pykka,代码行数:7,代码来源:test_future.py

示例2: test_get_all_can_be_called_multiple_times

 def test_get_all_can_be_called_multiple_times(self):
     self.results[0].set(0)
     self.results[1].set(1)
     self.results[2].set(2)
     result1 = get_all(self.results)
     result2 = get_all(self.results)
     self.assertEqual(result1, result2)
开发者ID:0xD3ADB33F,项目名称:pykka,代码行数:7,代码来源:future_test.py

示例3: test_get_all_can_be_called_multiple_times

def test_get_all_can_be_called_multiple_times(futures):
    futures[0].set(0)
    futures[1].set(1)
    futures[2].set(2)

    result1 = get_all(futures)
    result2 = get_all(futures)

    assert result1 == result2
开发者ID:jodal,项目名称:pykka,代码行数:9,代码来源:test_future.py

示例4: refresh

    def refresh(self, uri=None):
        """
        Refresh library. Limit to URI and below if an URI is given.

        :param uri: directory or track URI
        :type uri: string
        """
        if uri is not None:
            backend = self._get_backend(uri)
            if backend:
                backend.library.refresh(uri).get()
        else:
            futures = [b.library.refresh(uri) for b in self.backends.with_library.values()]
            pykka.get_all(futures)
开发者ID:karlpilkington,项目名称:mopidy,代码行数:14,代码来源:library.py

示例5: get_images

    def get_images(self, uris):
        """Lookup the images for the given URIs

        Backends can use this to return image URIs for any URI they know about
        be it tracks, albums, playlists... The lookup result is a dictionary
        mapping the provided URIs to lists of images.

        Unknown URIs or URIs the corresponding backend couldn't find anything
        for will simply return an empty list for that URI.

        :param list uris: list of URIs to find images for
        :rtype: {uri: tuple of :class:`mopidy.models.Image`}

        .. versionadded:: 1.0
        """
        futures = [
            backend.library.get_images(backend_uris)
            for (backend, backend_uris)
            in self._get_backends_to_uris(uris).items() if backend_uris]

        results = {uri: tuple() for uri in uris}
        for r in pykka.get_all(futures):
            for uri, images in r.items():
                results[uri] += tuple(images)
        return results
开发者ID:ArcherSys,项目名称:Peridot,代码行数:25,代码来源:library.py

示例6: extract_recipes

def extract_recipes(ingredient_list):
    """
    Extracts recipes for a list of ingredients *Multi-Threaded Solution*
    :param ingredient_list: list of ingredients to serve the initial query
    :return: Dictionary of recipes (includes link and ingredient list for each recipe)
    """
    query = ", ".join(ingredient_list)
    # Initiate the search
    base_url = "http://allrecipes.com"
    entry = base_url + "/search/results/?wt=" + query + "&sort=re"
    start_page = requests.get(entry)
    tree = html.fromstring(start_page.content)
    response = tree.xpath('//article[contains(@class, \'grid-col--fixed-tiles\')]//@href')
    # Extract search result links
    links = set()
    for i in xrange(min(10, len(response))):
        if "recipe" in str(response[i]):
            links.add(base_url + response[i])
    # Spawn workers to process each link
    futures, workers = [], []
    for link in links:
        message = {'link': link}
        actor_ref = Worker.start()
        workers.append(actor_ref)
        futures.append(actor_ref.ask(message, block=False))
    # Collect and merge worker answers
    recipes = dict()
    answers = pykka.get_all(futures)
    for answer in answers:
        recipes[answer['name']] = dict()
        recipes[answer['name']]['ingredients'] = answer['ingredients']
        recipes[answer['name']]['link'] = answer['link']
    for worker in workers:
        worker.stop()
    return recipes
开发者ID:joshammock,项目名称:Groceraid,代码行数:35,代码来源:recipes.py

示例7: test_wait_all_is_alias_of_get_all

 def test_wait_all_is_alias_of_get_all(self):
     self.results[0].set(0)
     self.results[1].set(1)
     self.results[2].set(2)
     result1 = get_all(self.results)
     result2 = wait_all(self.results)
     self.assertEqual(result1, result2)
开发者ID:flaper87,项目名称:pykka,代码行数:7,代码来源:future_test.py

示例8: search

    def search(self, query=None, **kwargs):
        """
        Search the library for tracks where ``field`` contains ``values``.

        Examples::

            # Returns results matching 'a'
            search({'any': ['a']})
            search(any=['a'])

            # Returns results matching artist 'xyz'
            search({'artist': ['xyz']})
            search(artist=['xyz'])

            # Returns results matching 'a' and 'b' and artist 'xyz'
            search({'any': ['a', 'b'], 'artist': ['xyz']})
            search(any=['a', 'b'], artist=['xyz'])

        :param query: one or more queries to search for
        :type query: dict
        :rtype: list of :class:`mopidy.models.SearchResult`
        """
        query = query or kwargs
        futures = [
            b.library.search(**query) for b in self.backends.with_library]
        return [result for result in pykka.get_all(futures) if result]
开发者ID:rattboi,项目名称:mopidy,代码行数:26,代码来源:library.py

示例9: get_playlists

 def get_playlists(self, include_tracks=True):
     futures = [
         b.playlists.playlists for b in self.backends.with_playlists]
     results = pykka.get_all(futures)
     playlists = list(itertools.chain(*results))
     if not include_tracks:
         playlists = [p.copy(tracks=[]) for p in playlists]
     return playlists
开发者ID:dtony,项目名称:Pi-MusicBox,代码行数:8,代码来源:playlists.py

示例10: test_get_all_raises_timeout_if_not_all_futures_are_available

 def test_get_all_raises_timeout_if_not_all_futures_are_available(self):
     try:
         self.results[0].set(0)
         self.results[2].set(2)
         result = get_all(self.results, timeout=0)
         self.fail('Should timeout')
     except gevent.Timeout:
         pass
开发者ID:flaper87,项目名称:pykka,代码行数:8,代码来源:future_test.py

示例11: test_get_all_blocks_until_all_futures_are_available

def test_get_all_blocks_until_all_futures_are_available(futures):
    futures[0].set(0)
    futures[1].set(1)
    futures[2].set(2)

    result = get_all(futures)

    assert result == [0, 1, 2]
开发者ID:jodal,项目名称:pykka,代码行数:8,代码来源:test_future.py

示例12: _node_states

 def _node_states(self, size):
     states = pykka.get_all(rec.actor.get_state()
                            for rec in self.cloud_nodes.nodes.itervalues()
                            if ((size is None or rec.cloud_node.size.id == size.id) and
                                rec.shutdown_actor is None))
     states += ['shutdown' for rec in self.cloud_nodes.nodes.itervalues()
                if ((size is None or rec.cloud_node.size.id == size.id) and
                    rec.shutdown_actor is not None)]
     return states
开发者ID:151706061,项目名称:arvados,代码行数:9,代码来源:daemon.py

示例13: _node_states

 def _node_states(self, size):
     proxy_states = []
     states = []
     for rec in self.cloud_nodes.nodes.itervalues():
         if size is None or rec.cloud_node.size.id == size.id:
             if rec.shutdown_actor is None and rec.actor is not None:
                 proxy_states.append(rec.actor.get_state())
             else:
                 states.append("shutdown")
     return states + pykka.get_all(proxy_states)
开发者ID:tomclegg,项目名称:arvados,代码行数:10,代码来源:daemon.py

示例14: refresh

    def refresh(self, uri_scheme=None):
        """
        Refresh the playlists in :attr:`playlists`.

        If ``uri_scheme`` is :class:`None`, all backends are asked to refresh.
        If ``uri_scheme`` is an URI scheme handled by a backend, only that
        backend is asked to refresh. If ``uri_scheme`` doesn't match any
        current backend, nothing happens.

        :param uri_scheme: limit to the backend matching the URI scheme
        :type uri_scheme: string
        """
        if uri_scheme is None:
            futures = [b.playlists.refresh() for b in self.backends.with_playlists]
            pykka.get_all(futures)
            listener.CoreListener.send("playlists_loaded")
        else:
            backend = self.backends.with_playlists_by_uri_scheme.get(uri_scheme, None)
            if backend:
                backend.playlists.refresh().get()
                listener.CoreListener.send("playlists_loaded")
开发者ID:AndreaCrotti,项目名称:mopidy,代码行数:21,代码来源:playlists.py

示例15: run

def run(pool_size, *ips):
    # Start resolvers
    resolvers = [Resolver.start().proxy() for _ in range(pool_size)]

    # Distribute work by mapping IPs to resolvers (not blocking)
    hosts = []
    for i, ip in enumerate(ips):
        hosts.append(resolvers[i % len(resolvers)].resolve(ip))

    # Gather results (blocking)
    ip_to_host = zip(ips, pykka.get_all(hosts))
    pprint.pprint(list(ip_to_host))

    # Clean up
    pykka.ActorRegistry.stop_all()
开发者ID:jodal,项目名称:pykka,代码行数:15,代码来源:resolver.py


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