@@ -115,43 +115,14 @@ async def map(self, fn, iterable, exc_as_result=True):
115115 futures = await self .map_n (fn , iterable )
116116 await self .join ()
117117
118- result = []
118+ results = []
119119 for fut in futures :
120- if fut .exception ():
121- res = fut .exception () if exc_as_result else None
122- else :
123- res = fut .result ()
124- result .append (res )
125- return result
120+ res = _get_future_result (fut , exc_as_result )
121+ results .append (res )
122+ return results
126123
127124 async def iterwait (self , * arg , ** kw ): # TODO there's a way to support 3.5?
128125 raise NotImplementedError ('python3.6+ required' )
129126
130127 async def itermap (self , * arg , ** kw ): # TODO there's a way to support 3.5?
131128 raise NotImplementedError ('python3.6+ required' )
132-
133- '''
134- if sys.version_info >= (3, 6): # supports async generators
135-
136- async def iterwait(self, futures, *, flat=True, exc_as_result=True,
137- timeout=None, yield_when=aio.ALL_COMPLETED):
138-
139- _futures = futures[:]
140- while _futures:
141- done, _futures = await aio.wait(_futures, loop=self.loop,
142- timeout=timeout, return_when=yield_when)
143- if flat:
144- for fut in done:
145- yield _get_future_result(fut, exc_as_result)
146- else:
147- yield [_get_future_result(f, exc_as_result) for f in done]
148-
149- async def itermap(self, fn, iterable, *, flat=True, exc_as_result=True,
150- timeout=None, yield_when=aio.ALL_COMPLETED):
151-
152- futures = await self.map_n(fn, iterable)
153- generator = self.iterwait(futures, flat=flat, timeout=timeout,
154- exc_as_result=exc_as_result, yield_when=yield_when)
155- async for batch in generator:
156- yield batch # TODO is it possible to return a generator?
157- '''
0 commit comments