I already wrote my script using asyncio but found that the number of coroutines running simultaneously is too large and it often ends up hanging around.
So I would like
You might want to consider using aiostream.stream.map with the task_limit
argument:
from aiostream import stream, pipe
async def main():
xs = stream.iterate(players)
ys = stream.map(xs, my_func, task_limit=100)
zs = stream.list(ys)
results = await zs
Same approach using pipes:
async def main():
results = await (
stream.iterate(players) |
pipe.map(my_func, task_limit=100) |
pipe.list())
See the aiostream project page and the documentation for further information.
Disclaimer: I am the project maintainer.