From: Claudio-Daniel Freire Date: Fri, 29 Apr 2011 08:00:48 +0000 (+0200) Subject: Fix parallel execution bug that only ran connect/preconfigure stuff on the last testbed: X-Git-Tag: nepi_v2~105 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=dc2f29cf0e796fc8a1f8f07ff48e1d7a05dd3b5e;p=nepi.git 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) --- 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