-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
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...
Metadata
Metadata
Assignees
Labels
No labels