class_docstr: A rendezvous implementation that uses `etcd <https://etcd.io/>`__ as the backend store.
class_docstr_tok: ["A","rendezvous","implementation","that","uses","`","etcd","<","https",":","\/\/etcd.io\/",">","`","__","as","the","backend","store","."]
docstr: Helper method for the join phase.
docstr_tok: ["Helper","method","for","the","join","phase","."]
code: def wait_for_peers(self, expected_version):
      """Helper method for the join phase."""
      active_version, state = self.get_rdzv_state()
      while True:
          if (
              state["status"] == "frozen"
              and state["version"] == expected_version
          ):
              # Success, all peers arrived.
              return active_version
  
          elif (
              state["status"] == "joinable"
              and state["version"] == expected_version
          ):
              # Continue waiting for any interesting events.
              active_version, state = self.try_wait_for_state_change(
                  etcd_index=active_version.etcd_index + 1
              )
  
          else:
              # No valid transition possible at this point
              raise EtcdRendezvousRetryableFailure(
                  "Rendezvous state transition no longer possible. Must re-enter."
              )
  
imports: import json
  import logging
  import sys
  import threading
  import time
  from typing import Optional
  import etcd
  from torch.distributed.elastic.rendezvous import RendezvousClosedError, RendezvousError, RendezvousHandler, RendezvousParameters, RendezvousTimeoutError
  from .utils import parse_rendezvous_endpoint
  from .etcd_store import EtcdStore, cas_delay
label_desc: Use image node_id 10 for calling the EtcdRendezvous obj's underlying member method code with example usage: obj.wait_for_peers(expected_version) and returns: active_version