Flock Base class

Base class used to build the ListAsync, DataFrameAsync and FunctionAsync classes.

You should avoid using this class inside your code. The interface might change without previous notice.

class flockmp.base.BaseMultiProc(poolSize=5, timeOutError=50, context='spawn')

BaseMultiProc is a class to apply and manage multiprocessing tasks within functions.

Parameters:
  • poolSize (int) – amount of resources set to be processed the same time (default = 5)
  • timeOutError (int) – degree of tolerance for waiting a process to end (default = 50)
  • context (str) – way of starting a process (depends os the platform). It can be “spawn”, “fork” or “forkserver” (`default`=”spawn”)
executeAsync(function, iterator)

Method executeAsync() executes a function asynchronally, given a set of iterators.

Parameters:
  • function (func) – a function in which is desired to be ran multiprocessed and asynchronally
  • iterator (iter) – variable in wich the function will be applied

Returns the result of the function given a set of arguments of that function.

Example

bp = BaseMultiProc()
iterator = list(range(10))
res = bp.executeAsync(lambda x: x ** 2, iterator)