in elastic_transport/_node_pool.py [0:0]
def add(self, node_config: NodeConfig) -> None:
try: # If the node was previously removed we mark it as "in the pool"
self._removed_nodes.remove(node_config)
except KeyError:
pass
with self._all_nodes_write_lock:
# We don't error when trying to add a duplicate node
# to the pool because threading+sniffing can call
# .add() on the same NodeConfig.
if node_config not in self._all_nodes:
node = self._node_class(node_config)
self._all_nodes[node.config] = node
# Update the flag to disable optimizations. Also ensures that
# .resurrect() starts getting called so our added node makes
# it way into the alive nodes.
self._all_nodes_len_1 = False
# Start the node as dead because 'dead_nodes' is thread-safe.
# The node will be resurrected on the next call to .get()
self._dead_consecutive_failures[node.config] = 0
self._dead_nodes.put((time.time(), node))