From 96d8faef18d09fa5c7fcb2d9fdea6942ff95f039 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 16 Nov 2023 10:11:30 +0100 Subject: [PATCH] Fix node id --- esds/node.py | 6 ++---- esds/simulator.py | 2 +- 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())