[ecspy] r127 committed - Modified mp_evaluator to pass the actual args dictionary to the true e...

1 view
Skip to first unread message

ec...@googlecode.com

unread,
Feb 4, 2012, 4:47:55 PM2/4/12
to ec...@googlegroups.com
Revision: 127
Author: aaron.lee.garrett
Date: Sat Feb 4 13:47:24 2012
Log: Modified mp_evaluator to pass the actual args dictionary to the
true evaluation function. To be passed, all elements in the dictionary must
be pickle-able, but the ones that aren't are currently being removed before
passing it.
http://code.google.com/p/ecspy/source/detail?r=127

Modified:
/trunk/ecspy/evaluators.py

=======================================
--- /trunk/ecspy/evaluators.py Sun Nov 20 13:57:01 2011
+++ /trunk/ecspy/evaluators.py Sat Feb 4 13:47:24 2012
@@ -189,11 +189,19 @@
nprocs = args['mp_num_cpus']
except KeyError:
nprocs = multiprocessing.cpu_count()
-
+ mp_args = {}
+ for key in args:
+ try:
+ pickle.dumps(args[key])
+ mp_args[key] = args[key]
+ except TypeError, pickle.PickleError:
+ logger.debug('in mp_evaluator: unable to pickle args
parameter %s' % key)
+ pass
+
start = time.time()
try:
pool = multiprocessing.Pool(processes=nprocs)
- results = [pool.apply_async(evaluator, ([c], {})) for c in
candidates]
+ results = [pool.apply_async(evaluator, ([c], mp_args)) for c in
candidates]
pool.close()
return [r.get()[0] for r in results]
except (OSError, RuntimeError) as e:

Reply all
Reply to author
Forward
0 new messages