Fix parallel execution bug that only ran connect/preconfigure stuff on the last testbed:
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Fri, 29 Apr 2011 08:00:48 +0000 (10:00 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Fri, 29 Apr 2011 08:00:48 +0000 (10:00 +0200)
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

index 7ac77a4..f74e23f 100644 (file)
@@ -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