[Python-ideas] The async API of the future: yield-from
Serhiy Storchaka
storchaka at gmail.com
Mon Oct 15 00:41:01 CEST 2012
On 14.10.12 22:38, Terry Reedy wrote:
> On 10/14/2012 1:42 PM, Guido van Rossum wrote:
> > But then the caller would have to sort through the results and check
> > for exceptions. I want the caller to be able to use try/except as
> > well.
> OK. Then ...
def par(*args):
results = []
exceptions = False
for task in args:
try:
result = yield from task
if exceptions:
results.append(StopIteration(result))
else:
results.append(result)
except Exception as exc:
results = [StopIteration(result) for result in results]
results.append(exc)
exceptions = True
if not exceptions:
return results
else:
exc = MultiXException()
exc.results = results
raise exc
More information about the Python-ideas
mailing list