Multiprocessing your Functions¶
- Flock supports the following list of functions:
- Instance methods
- Class methods
- Regular functions
If your function needs a connection to any database to perform its computation, please use the
FunctionAsyncis a class to apply and manage multiprocessing tasks within functions.
apply(iterator, function, poolSize=5)¶
apply()executes a function asynchronously given an iterator.
- iterator (iter) – variable in which the function will be applied.
- function (func) – a function in which is desired to be ran multi-processed.
Returns the list with the results of function(iterator).
_list = list(range(2000)) res = FunctionAsync.apply(_list, lambda x: x ** 2 / 10)