summaryrefslogtreecommitdiff
path: root/esds/node.py
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-09-06 15:34:48 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2022-09-06 15:34:48 +0200
commit721801012ad7ae440b8f53d082cc0eefa3b37fca (patch)
treecd55735f6b70fb86199a7ddbb91e233d0043be40 /esds/node.py
parent0db52b3e8393f22ce62728729bd78aa379fc8282 (diff)
Debug plugins system
Diffstat (limited to 'esds/node.py')
-rw-r--r--esds/node.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/esds/node.py b/esds/node.py
index 59b6f96..aa3cf22 100644
--- a/esds/node.py
+++ b/esds/node.py
@@ -22,11 +22,6 @@ class Node:
def plugin_register(self,plugin):
self.plugins.append(plugin)
- def plugin_handle_requests(self):
- # Take plugins notification into account
- for key in list(self["plugin_notify"]):
- self.plugin_notify(key,self["plugin_notify"].pop(key))
-
def plugin_notify(self,reason,args):
"""
This function strives to avoid using Python specific features
@@ -145,15 +140,17 @@ class Node:
self["request"]="send"
self["state"]="call_blocking"
ack=self.wait_ack(["send","timeout","send_cancel"])
+ status=-1
if ack[0] == "timeout":
self["request"]="send_cancel"
self["state"]="call_non_blocking"
self.wait_ack(["send_cancel"])
- return -1
- self["request"]="timeout_remove"
- self["state"]="call_non_blocking"
- self.wait_ack(["timeout_remove"])
- return ack[1]
+ else:
+ self["request"]="timeout_remove"
+ self["state"]="call_non_blocking"
+ self.wait_ack(["timeout_remove"])
+ status=ack[1]
+ return status
def receive(self,interface):
if interface not in self["interfaces"]:
@@ -185,14 +182,15 @@ class Node:
self.rargs=interface
self["state"]="call_blocking"
ack=self.wait_ack(["receive","timeout"])
- if ack[0] == "timeout":
- return (-1,None)
- self["request"]="timeout_remove"
- self["state"]="call_non_blocking"
- self.wait_ack(["timeout_remove"])
- data,start_at,end_at=self["interfaces"][interface].get()
- self.plugin_notify("receivet_return",(interface,data,start_at,end_at))
- return (0,data)
+ result=(-1,None)
+ if ack[0] != "timeout":
+ self["request"]="timeout_remove"
+ self["state"]="call_non_blocking"
+ self.wait_ack(["timeout_remove"])
+ data,start_at,end_at=self["interfaces"][interface].get()
+ self.plugin_notify("receivet_return",(interface,data,start_at,end_at))
+ result=(0,data)
+ return result
def wait_ack(self, ack_types):
"""
@@ -202,7 +200,9 @@ class Node:
ack=None
while True:
ack=self.rqueue.get() # Wait for simulator acknowledgments
- if ack[0] not in ack_types:
+ if ack[0] == "plugin_notify":
+ self.plugin_notify(ack[1],ack[2]) # TODO: what is ack_types received before "plugin_notify" ?
+ elif ack[0] not in ack_types:
ack_buffer.append(ack)
else:
break