WorkerWithKwargs

class bigmultipipe.WorkerWithKwargs(function, **kwargs)[source]

Bases: object

Class to hold static kwargs for use with, e.g., multiprocessing.pool.Pool.map()

Parameters
functionfunction

Function called by worker()

kwargskwargs

kwargs to be passed to function

Examples

This code:

>>> def add_mult(a, to_add=0, to_mult=1):
>>>     return (a + to_add) * to_mult
>>> 
>>> wwk = WorkerWithKwargs(add_mult, to_add=3, to_mult=10)
>>> print(wwk.worker(3))
>>> print(wwk.worker(3)) 
60

is equivalent to:

>>> print(add_mult(3, to_add=3, to_mult=10))
>>> w3 = add_mult(3, to_add=3, to_mult=10)
>>> w3 
60
Attributes
functionfunction

Function called by worker()

kwargskwargs

kwargs to be passed to function

Methods Summary

worker(*args)

Method called to execute function with saved **kwargs

Methods Documentation

worker(*args)[source]

Method called to execute function with saved **kwargs

Parameters
*argsany type
Returns
function(*args, **kwargs)