rhoboro / asynconsumer Goto Github PK
View Code? Open in Web Editor NEWasynconsumer is a simple library for processing each items within iterable using asyncio.
License: Apache License 2.0
asynconsumer is a simple library for processing each items within iterable using asyncio.
License: Apache License 2.0
async_runの引数のtargets
がstringだった場合には1文字ずつparseされると思うのですが、
個人的な感覚としては、listに自動的に変換される処理のが自然なのかなと思いました。
ただ、pythonだとExplicit is better than implicit.
という考え方があるので
Python的にはどちらが好ましいのかというのを教えていただけますか?
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']
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.