summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-09-07 09:15:49 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2022-09-07 09:15:49 +0200
commit2fb979cfec7eba0c4168f7728045426396d2b8f0 (patch)
treea56d4b2b9a8bfb58ce0ef11bd10f85e6a92aa240
parent02aac0ef999cbb6d9d727de5397818fddaa6bb65 (diff)
Debug plugin callback and simulation ending
-rw-r--r--esds/node.py4
-rw-r--r--esds/simulator.py17
2 files changed, 13 insertions, 8 deletions
diff --git a/esds/node.py b/esds/node.py
index 03c7457..e47df98 100644
--- a/esds/node.py
+++ b/esds/node.py
@@ -88,7 +88,8 @@ class Node:
self["request"]="wait_end"
self["state"]="call_blocking"
self.wait_ack(["wait_end"])
- self.wait_ack(["sim_end"])
+ ack=self.wait_ack(["sim_end"])
+ self.rqueue.put(ack) # To allow self.run() to catch the sim_end event
def turn_off(self):
self["turned_on"]=False
@@ -227,3 +228,4 @@ class Node:
self.args=args # Allow access to arguments
self.node.execute(self)
self["state"]="terminated"
+ self.wait_ack(["sim_end"])
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