1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
11 '''Creates a Future which returns a list of results from each Future in
14 return Future(callback
=lambda: [f
.Get() for f
in futures
])
18 '''Stores a value, error, or callback to be used later.
20 def __init__(self
, value
=_no_value
, callback
=None, exc_info
=None):
22 self
._callback
= callback
23 self
._exc
_info
= exc_info
24 if (self
._value
is _no_value
and
25 self
._callback
is None and
26 self
._exc
_info
is None):
27 raise ValueError('Must have either a value, error, or callback.')
30 '''Gets the stored value, error, or callback contents.
32 if self
._value
is not _no_value
:
34 if self
._exc
_info
is not None:
37 self
._value
= self
._callback
()
40 self
._exc
_info
= sys
.exc_info()
44 exc_info
= self
._exc
_info
45 raise exc_info
[0], exc_info
[1], exc_info
[2]