I am developing a search tree agent which is able to use multi threads to grow its nodes.
every node has these features:
import threading
def __init__(self, move=None, parent=None):
self.lock = threading.Lock()
self.lock.acquire()
self.move = move
self.parent = parent
self.N = 0
self.Q = 0
self.children = {}
self.lock.release()
As you can see whenever a node is initialized, it is locked to avoid possible duplicates of node.
In some place of my code I put all the nodes of a parent node in a list and select randomly:
max_nodes = [n for n in node.children.values()]
node = random.choice(max_nodes)
If during the creation of max_nodes list, a node was locked (nodes could be locked from time to time), what would happen to the random selection.
does it wait for all the nodes to be released or not?
I ask the question because I get this error multiple times:
cannot choose from an empty list
Aucun commentaire:
Enregistrer un commentaire