summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <loic.guegan@mailbox.org>2023-11-16 10:11:30 +0100
committerLoic Guegan <loic.guegan@mailbox.org>2023-11-16 10:11:30 +0100
commit96d8faef18d09fa5c7fcb2d9fdea6942ff95f039 (patch)
tree85175b65e43a4596418c1af50b6541e304919bad
parent2b92cd319548d44ec82c57ebcde422f3e32b2e3e (diff)
Fix node id
-rw-r--r--esds/node.py6
-rw-r--r--esds/simulator.py2
2 files changed, 3 insertions, 5 deletions
diff --git a/esds/node.py b/esds/node.py
index bca9a5f..455bd24 100644
--- a/esds/node.py
+++ b/esds/node.py
@@ -2,14 +2,12 @@ import threading,importlib,queue
from esds.rcode import RCode
class Node:
- available_node_id=0
- def __init__(self,src,interfaces,grp):
+ def __init__(self,src,interfaces,grp,node_id):
"""
self.chest: contains mutex protected data
"""
- self.node_id=Node.available_node_id
+ self.node_id=node_id
self.grp=grp # Node group
- Node.available_node_id+=1 # Refresh node id
self.src=src # Store the node source code
self.args=None # Store the node arguments (passed through Simulator.create_node()
self.rargs=None # Store the requests arguments
diff --git a/esds/simulator.py b/esds/simulator.py
index 3433d72..14ee7b4 100644
--- a/esds/simulator.py
+++ b/esds/simulator.py
@@ -83,7 +83,7 @@ class Simulator:
if intf not in self.netmat.keys():
self.log("Cannot create node "+str(Node.available_node_id)+": interface "+ intf + " unknown")
exit(1)
- node=Node(src, interfaces, grp)
+ node=Node(src, interfaces, grp, len(self.nodes)) # len(self.nodes) starts at 0 since append just below
self.nodes.append(node)
thread=threading.Thread(target=node.run,args=[args])
thread.setDaemon(True) # May not work on old version of pythons but allow to kill threads when main thread ends (see Node.abort())