In [1]: from asynconsumer.core import async_run
In [2]: import asyncio
In [3]: async def coro(target):
...: print('start: {}'.format(target))
...: await asyncio.sleep(1)
...: print('end: {}'.format(target))
...: # 戻り値のリストがasync_runの戻り値になる
...: return target.upper()
In [4]: results = async_run(['ham', 'egg', 'spam'], coro, concurrency=2)
start: ham
start: egg
end: ham
end: egg
start: spam
end: spam
In [5]: results
Out[5]: ['HAM', 'EGG', 'SPAM']
In [6]: results = async_run('targets', coro, concurrency=2)
start: t
start: a
end: t
end: a
start: r
start: g
end: r
end: g
start: e
start: t
end: e
end: t
start: s
end: s
In [7]: results
Out[7]: ['T', 'A', 'R', 'G', 'E', 'T', 'S']