Numerical Experiments Toolbox.
Example
amfe.num_exp_toolbox.
apply_async
(pool, fun, args)[source]¶Run a function asynchrounously.
Parameters: |
|
---|---|
Returns: | job_result – Return value of the apply_async method of the Pool-class |
Return type: | multiprocessing.Pool.apply instance |
Examples
>>> import multiprocessing
>>> pool = multiprocessing.Pool()
>>>
>>> def func(a,b):
>>> return a + b
>>>
>>> job_result = amfe.apply_async(pool, func, [1, 2])
>>> job_result.get()
3
Note
The apply async stuff needs to pickle an object. As some nested functions used in amfe cannot be pickled, the dill module has to be used. This is done by the given method.