Esempio n. 1
0
    def threaded_executor(params):
        tp = TPool()
        if len_configs_structs > 1:
            results = tp.map(
                lambda t: t[0](t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], configured_n), params
            )
        else:
            t = params[0]
            results = t[0](t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], configured_n)

        tp.close()
        return results
Esempio n. 2
0
#!/usr/bin/env python
#
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
# Copyright (c) 1997-2014 California Institute of Technology.
# License: 3-clause BSD.  The full license text is available at:
#  - http://trac.mystic.cacr.caltech.edu/project/pathos/browser/pathos/LICENSE

from pathos.multiprocessing import ProcessingPool as Pool
from pathos.multiprocessing import ThreadingPool as TPool
pool = Pool()
tpool = TPool()


# pickle fails for nested functions
def adder(augend):
    zero = [0]

    def inner(addend):
        return addend + augend + zero[0]

    return inner


# build from inner function
add_me = adder(5)

# build from lambda functions
squ = lambda x: x**2

# test 'dilled' multiprocessing for inner
print "Evaluate 10 items on 2 proc:"