From 2fb979cfec7eba0c4168f7728045426396d2b8f0 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Wed, 7 Sep 2022 09:15:49 +0200 Subject: Debug plugin callback and simulation ending --- esds/simulator.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'esds/simulator.py') diff --git a/esds/simulator.py b/esds/simulator.py index f56dfcb..39e374c 100644 --- a/esds/simulator.py +++ b/esds/simulator.py @@ -360,10 +360,10 @@ class Simulator: return np.arange(0,selector.shape[0])[selector] def notify_node_plugins(self,node,callback,args): - node[pending_plugin_notify]+=1 - self.nodes[int(event[2][1])].rqueue.put(("plugin_notify",callback,args)) + node["pending_plugin_notify"]+=1 + node.rqueue.put(("plugin_notify",callback,args)) # Now ensure that all callbacks are called before continuing - while node[pending_plugin_notify] > 0: + while node["pending_plugin_notify"] > 0: pass def add_event(self,event_type,event_ts,event,priority=2): @@ -406,10 +406,13 @@ class Simulator: if len(self.events) <= 0 or len(self.events) == 1 and self.events[0,0] == 3: # Notify nodes that wait for the end of the simulation # Note that we do not allow them to create new events (even if they try, they will not be processed) - for node_id in self.wait_end_nodes: - self.nodes[node_id]["state"]="running" - self.nodes[node_id].rqueue.put(("sim_end",0)) - self.sync_node_non_blocking(self.nodes[node_id]) # Allow them for make non-blocking call requests (printing logs for example) + for node in self.nodes: + if node["state"] != "terminated": + node["state"]="running" + node.rqueue.put(("sim_end",0)) + self.sync_node_non_blocking(node) # Allow them for make non-blocking call requests (printing logs for example) + else: + node.rqueue.put(("sim_end",0)) break # End the event processing loop # Update simulation time -- cgit v1.2.3