their result method will be called automatically when they are
ready. Additionally, lists of any combination of these objects may
be yielded; the result is a list of the results of each yield point
- in the same order.
+ in the same order. Yielding dicts with these objects in values will
+ return dict with results at the same keys.
.. autoclass:: Task
def get(self):
yield gen.Task(AsyncHTTPClient().fetch, "http://example.com")
-You can also yield a list of ``Futures`` and/or ``Tasks``, which will be
-started at the same time and run in parallel; a list of results will
+You can also yield a list or dict of ``Futures`` and/or ``Tasks``, which will be
+started at the same time and run in parallel; a list or dict of results will
be returned when they are all finished::
@gen.coroutine
http_client = AsyncHTTPClient()
response1, response2 = yield [http_client.fetch(url1),
http_client.fetch(url2)]
+ response_dict = yield dict(response3=http_client.fetch(url3),
+ response4=http_client.fetch(url4))
+ response3 = response_dict['response3']
+ response4 = response_dict['response4']
For more complicated interfaces, `Task` can be split into two parts:
`Callback` and `Wait`::