From dc2f29cf0e796fc8a1f8f07ff48e1d7a05dd3b5e Mon Sep 17 00:00:00 2001 From: Claudio-Daniel Freire Date: Fri, 29 Apr 2011 10:00:48 +0200 Subject: [PATCH] Fix parallel execution bug that only ran connect/preconfigure stuff on the last testbed: lambda : testbed.do_something only does it for the last value of the variable "testbed" Testbed is a free variable, so it takes the value of the variable then the lambda is called, which is usually the last value it took in the loop. The correct way would be: lambda testbed=testbed : testbed.do_something Since that "freezes" the value of the "testbed" variable. An easier and nicer way is to use bound methods: testbed.do_something (without lambda) --- src/nepi/core/execute.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/nepi/core/execute.py b/src/nepi/core/execute.py index 7ac77a4a..f74e23f0 100644 --- a/src/nepi/core/execute.py +++ b/src/nepi/core/execute.py @@ -355,22 +355,16 @@ class ExperimentController(object): # perform create-connect in parallel, wait # (internal connections only) - self._parallel([lambda : testbed.do_create() + self._parallel([testbed.do_create for testbed in self._testbeds.itervalues()]) - # TODO! DEBUG!!!! - # ONLY THE LAST TESTBED HAS ELEMENTS CREATED!!! - #for testbed in self._testbeds.itervalues(): - # print testbed._testbed_id - # print testbed._elements - - self._parallel([lambda : testbed.do_connect_init() + self._parallel([testbed.do_connect_init for testbed in self._testbeds.itervalues()]) - self._parallel([lambda : testbed.do_connect_compl() + self._parallel([testbed.do_connect_compl for testbed in self._testbeds.itervalues()]) - self._parallel([lambda : testbed.do_preconfigure() + self._parallel([testbed.do_preconfigure for testbed in self._testbeds.itervalues()]) # resolve netrefs -- 2.47.0