Skip to content

Commit c22ee2e

Browse files
committed
couple of tiny corrections
1 parent b6de1e1 commit c22ee2e

File tree

3 files changed

+9
-36
lines changed

3 files changed

+9
-36
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ async def details(todo=range(1,11)):
115115

116116
## TODO:
117117

118-
- [ ] cancelled, timeouts
119118
- [ ] callbacks
119+
- [ ] setup
120+
- [ ] cancelled, timeouts
120121
- [x] tests
122+
- [ ] loadtests
121123
- [x] usage
122-
- [ ] examples
123124
- [ ] docs
125+
- [ ] examples
124126
- [ ] readme

asyncio_pool/base_pool.py

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
'''

tests/test_spawn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async def wrk(n):
1616

1717
async with AioPool(size=2) as pool:
1818
for i in range(1,6):
19-
await pool.spawn(wrk(i)) # waits for pool to be awailable
19+
await pool.spawn(wrk(i)) # waits for pool to be available
2020
assert len(started) != 0 # so atm some of workers should start
2121

2222
started.clear()

0 commit comments

Comments
 (0)