Sends the request to execute `target' in parallel with the given `args' and `kwargs' argument values. The
`valrange' value is used to set the value range members of the AlgorithmProcess objects, `numprocs' is the
number of processes to execute `target' on (1 will cause `target' to be executed in the main process, a value
<=0 will mean all the processes will be used), and `task' is the (possibly None) Task object to report
progress to. The return value is a Future object which will contain the results or exceptions thrown.
The `target' routine must exist in a module scope at runtime so inner routines or dynamically created routines
cannot be used here. When called, the first argument will be the AlgorithmProcess object followed by those in
`args' and `kwargs'. The AlgorithmProcess instance will be different for each process `target' is called in,
its members will state which process and the subset of `valrange' assigned to it. The expectation is that
`valrange' is the number of elements `target' is used to operate on, when called each process is assigned a
subset of the range [0,`valrange') and the internal algorithm of `target' is expected to iterate over those
values only.
The optional argument "partitionArgs" in `kwargs' may contain a tuple containing the members in `args' which
are iterable and which should be partitioned amongst the processes. Values in `args' and `kwargs' are normally
copied to each process, so this allows large iterables to be partitioned and not needlessly duplicated.
The @concurrent can be used to wrap the invocation of callProcessFunc() within the function definition itself.
The first argument of the routine must still be the AlgorithmProcess object but when called three arguments
representing `valrange', `numprocs', and `task' must be provided instead. The routine will also no block until
the processing is complete and return the results instead of a Future object.
Example:
def testfunc(process):
return (process.index,int(process.startval),int(process.endval))
result=ProcessServer.globalServer.callProcessFunc(50,4,None,testfunc)
printFlush(listResults(result()))
Output: [(0, 0, 12), (1, 12, 25), (2, 25, 37), (3, 37, 50)]
Example:
@concurrent
def testfunc(process,values):
return (process.index,values)
values=range(20)
result=testfunc(len(values),3,None,values,partitionArgs=(values,))
printFlush(listResults(result))
Output: [(0, [0, 1, 2]), (1, [3, 4, 5]), (2, [6, 7, 8, 9])]