本文整理汇总了Python中pykka.get_all函数的典型用法代码示例。如果您正苦于以下问题:Python get_all函数的具体用法?Python get_all怎么用?Python get_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_all函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: find_exact
def find_exact(self, query=None, uris=None, **kwargs):
"""
Search the library for tracks where ``field`` is ``values``.
If the query is empty, and the backend can support it, all available
tracks are returned.
If ``uris`` is given, the search is limited to results from within the
URI roots. For example passing ``uris=['file:']`` will limit the search
to the local backend.
Examples::
# Returns results matching 'a' from any backend
find_exact({'any': ['a']})
find_exact(any=['a'])
# Returns results matching artist 'xyz' from any backend
find_exact({'artist': ['xyz']})
find_exact(artist=['xyz'])
# Returns results matching 'a' and 'b' and artist 'xyz' from any
# backend
find_exact({'any': ['a', 'b'], 'artist': ['xyz']})
find_exact(any=['a', 'b'], artist=['xyz'])
# Returns results matching 'a' if within the given URI roots
# "file:///media/music" and "spotify:"
find_exact(
{'any': ['a']}, uris=['file:///media/music', 'spotify:'])
find_exact(any=['a'], uris=['file:///media/music', 'spotify:'])
:param query: one or more queries to search for
:type query: dict
:param uris: zero or more URI roots to limit the search to
:type uris: list of strings or :class:`None`
:rtype: list of :class:`mopidy.models.SearchResult`
"""
query = query or kwargs
futures = [
backend.library.find_exact(query=query, uris=backend_uris)
for (backend, backend_uris)
in self._get_backends_to_uris(uris).items()]
return [result for result in pykka.get_all(futures) if result]
开发者ID:AndroidMarv,项目名称:mopidy,代码行数:44,代码来源:library.py
示例17: search
def search(self, **query):
"""
Search the library for tracks where ``field`` contains ``values``.
Examples::
# Returns results matching 'a'
search(any=['a'])
# Returns results matching artist 'xyz'
search(artist=['xyz'])
# Returns results matching 'a' and 'b' and 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.Track`
"""
futures = [
b.library.search(**query) for b in self.backends.with_library]
results = pykka.get_all(futures)
return list(itertools.chain(*results))
开发者ID:AndreaCrotti,项目名称:mopidy,代码行数:21,代码来源:library.py
示例18: get_distinct
def get_distinct(self, field, query=None):
"""
List distinct values for a given field from the library.
This has mainly been added to support the list commands the MPD
protocol supports in a more sane fashion. Other frontends are not
recommended to use this method.
:param string field: One of ``artist``, ``albumartist``, ``album``,
``composer``, ``performer``, ``date``or ``genre``.
:param dict query: Query to use for limiting results, see
:meth:`search` for details about the query format.
:rtype: set of values corresponding to the requested field type.
.. versionadded:: 1.0
"""
futures = [b.library.get_distinct(field, query)
for b in self.backends.with_library.values()]
result = set()
for r in pykka.get_all(futures):
result.update(r)
return result
开发者ID:ArcherSys,项目名称:Peridot,代码行数:22,代码来源:library.py
示例19: _nodes_busy
def _nodes_busy(self, size):
return sum(1 for busy in
pykka.get_all(rec.actor.in_state('busy') for rec in
self.cloud_nodes.nodes.itervalues()
if rec.cloud_node.size.id == size.id)
if busy)
开发者ID:2lenet,项目名称:arvados,代码行数:6,代码来源:daemon.py
示例20: _actor_nodes
def _actor_nodes(self, node_actor):
return pykka.get_all([node_actor.cloud_node, node_actor.arvados_node])
开发者ID:faustvault,项目名称:arvados,代码行数:2,代码来源:daemon.py
注:本文中的pykka.get_all函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论