Open fabridamicelli opened 3 months ago
Here's an actually running example code:
import asyncio
from aiomultiprocess import Pool
async def f(i: int) -> int:
await asyncio.sleep(0.1)
return i
async def main():
async with Pool() as p:
vals_seq = [0, 1, 2]
vals_iter = (i for i in range(3))
print(await p.map(f, vals_seq))
print(await p.map(f, vals_iter))
if __name__ == "__main__":
asyncio.run(main())
which outputs:
First off: Thank you very much for this package! :)
Here's a little thing about type hints I found. In essence the Sequece type is too restrictive. The function map can deal as is with any iterable.
Description
The type of the arg
iterable
should be aIterable
instead ofSequence
. Here's pyright hint:And here's after the fix