feluxe / aioexec Goto Github PK
View Code? Open in Web Editor NEWasyncio executors, clean and simple.
License: Apache License 2.0
asyncio executors, clean and simple.
License: Apache License 2.0
It would be handy if the batch()
function could take AsyncGeneratorType
.
return await gather(
*Threads().batch(
Call(
my_func,
kind=item,
) async for item in my_async_gen
)
)
The current workaround is this:
with Threads() as pool:
futs = [
pool.call(
my_func,
kind=item,
) async for item in my_async_gen
]
return await gather(*(f for f in futs))
Currently we can use aioexec
for asyncio like this:
from aioexec import Procs
aysnc def my_async_func():
my_values = await asyncio.gather(
*Procs(3).batch(
Call(my_func, foo='bar'),
Call(my_func, foo='baz'),
Call(my_func, foo='qux'),
)
)
It would be nice to use Procs
from non-asyncio code as well:
from aioexec.sync import Procs, gather
def my_non_async_func():
# Call a single function in another process.
future = Procs(1).call(my_func, foo='baz')
my_value = future.result()
# Or in one line:
result = Procs(1).call(my_func, foo='baz').result()
# Call multiple functions in a pool:
future = gather(
*Procs(3).batch(
Call(my_func, foo='bar'),
Call(my_func, foo='baz'),
Call(my_func, foo='qux'),
)
)
results = future.result()
# Call multiple functions in a pool and returns values as completed:
future = as_completed(
*Procs(3).batch(
Call(my_func, foo='bar'),
Call(my_func, foo='baz'),
Call(my_func, foo='qux'),
)
)
results = future.result()
# etc...
It would be handy if you could run async functions in a new process as well, e.g.:
Procs().batch(
Call(myAsyncFunc, arg1),
Call(mySyncFunc, arg1)
)
Maybe a context for aioexec
classes would be handy. E.g.:
async with Procs(5) as procs:
a = await procs.call(my_func, foo='baz')
# Do other stuff
b = await procs.call(my_func, foo='baz')
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.