ctools  2.0.0
 All Classes Namespaces Files Functions Variables Macros Pages
cscripts.mputils Namespace Reference

Functions

def nthreads
 
def process
 
def mpfunc
 

Function Documentation

def cscripts.mputils.mpfunc (   args)
Multiprocessing function

Parameters
----------
args : tuple
    Tuple comprised of class, function name and function argument

Returns
-------
result, info : tuple
    Tuple of function result and information

Definition at line 121 of file mputils.py.

def cscripts.mputils.nthreads (   cls)
Determines the number of parallel processes to use

The number is based on the user parameter "nthreads" and the availability
of the multiprocessing module.

Parameters
----------
cls : `~ctools.cscript`
    cscript class

Returns
-------
nthreads : int
    Number of threads

Definition at line 26 of file mputils.py.

Referenced by cterror.get_parameters(), ctlike.get_parameters(), ctfindvar.get_parameters(), ctobssim.get_parameters(), ctmodel.get_parameters(), and ctbin.get_parameters().

def cscripts.mputils.process (   nthreads,
  function,
  args 
)
Execute function in parallel

Parameters
----------
nthreads : int
    Number of parallel threads
function : Python function
    Function to be executed in parallel
args : list of tuples
    Function arguments for each evaluation

Returns
-------
results : list of dicts
    List of function evaluation results

Definition at line 77 of file mputils.py.