From: Alina Quereilhac <alina.quereilhac@inria.fr>
Date: Tue, 24 May 2011 14:48:23 +0000 (+0200)
Subject: ns3 testbed small bugfix in the schedule_event
X-Git-Tag: nepi_v2~2^2~2
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=cbd2111b4e5bfacc8c8262535d79df7073764e48;p=nepi.git

ns3 testbed small bugfix in the schedule_event
---

diff --git a/src/nepi/testbeds/ns3/execute.py b/src/nepi/testbeds/ns3/execute.py
index a9ccd370..b975b7fa 100644
--- a/src/nepi/testbeds/ns3/execute.py
+++ b/src/nepi/testbeds/ns3/execute.py
@@ -140,13 +140,15 @@ class TestbedController(testbed_impl.TestbedController):
         """Schedules event on running experiment"""
         def execute_event(condition, has_event_occurred, func, *args):
             # exec func
-            func(*args)
-            # flag event occured
-            has_event_occurred[0] = True
-            # notify condition indicating attribute was set
-            condition.acquire()
-            condition.notifyAll()
-            condition.release()
+            try:
+                func(*args)
+            finally:
+                # flag event occured
+                has_event_occurred[0] = True
+                # notify condition indicating attribute was set
+                condition.acquire()
+                condition.notifyAll()
+                condition.release()
 
         # contextId is defined as general context
         contextId = long(0xffffffff)
@@ -163,9 +165,6 @@ class TestbedController(testbed_impl.TestbedController):
             while not has_event_occurred[0] and not self.ns3.Simulator.IsFinished():
                 condition.wait()
                 condition.release()
-                if not has_event_occurred[0]:
-                    raise RuntimeError('Event could not be scheduled : %s %s ' \
-                    % (repr(func), repr(args)))
 
     def _set_attribute(self, name, ns3_value, element):
         if self.status() == TESTBED_STATUS_STARTED: