From ffb703ecfdb8e7f4aa91a09608c89393d60bbd85 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 3 Aug 2015 23:00:54 -0400 Subject: [PATCH] Fix multiprocessing example when using Python 3 In Python 3, 'map' returns an object which evalutes the function as it is consumed, not when 'map' is called. Therefore, the correct comparison to pool.map(...) is list(map(...)). --- .../examples/transport/multiprocessing_viscosity.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/cython/cantera/examples/transport/multiprocessing_viscosity.py b/interfaces/cython/cantera/examples/transport/multiprocessing_viscosity.py index f895a0761..af981a465 100644 --- a/interfaces/cython/cantera/examples/transport/multiprocessing_viscosity.py +++ b/interfaces/cython/cantera/examples/transport/multiprocessing_viscosity.py @@ -64,13 +64,13 @@ def serial(mech, predicate, nTemps): P = ct.one_atm X = 'CH4:1.0, O2:1.0, N2:3.76' init_process(mech) - y = map(predicate, - zip(itertools.repeat(mech), - np.linspace(300, 900, nTemps), - itertools.repeat(P), - itertools.repeat(X))) + y = list(map(predicate, + zip(itertools.repeat(mech), + np.linspace(300, 900, nTemps), + itertools.repeat(P), + itertools.repeat(X)))) return y - + if __name__ == '__main__': # For functions where the work done in each subprocess is substantial, # significant speedup can be obtained using the multiprocessing module.