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: Announce this worker is waiting (via num_workers_waiting counter) to join next
  rendezvous, but only if state and version match.
docstr_tok: ["Announce","this","worker","is","waiting","(","via","num_workers_waiting","counter",")","to","join","next","rendezvous",",","but","only","if","state","and","version","match","."]
code: def announce_self_waiting(self, expected_version):
      """
      Announce this worker is waiting (via num_workers_waiting counter) to join next
      rendezvous, but only if state and version match.
      """
      while True:
          cas_delay()
          active_version, state = self.get_rdzv_state()
  
          if (
              state["status"] != "final"
              or state["version"] != expected_version
          ):
              raise EtcdRendezvousRetryImmediately()
  
          # Increment counter to signal an additional waiting worker.
          state["num_workers_waiting"] += 1
  
          try:
              active_version = self.client.test_and_set(
                  key=self.get_path("/rdzv/active_version"),
                  value=json.dumps(state),
                  prev_value=active_version.value,
              )
              return active_version
  
          except etcd.EtcdCompareFailed:
              log.info(
                  "Announce self as waiting CAS unsuccessful, retrying"
              )
  
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 13 for calling the EtcdRendezvous obj's underlying member method code with example usage: obj.announce_self_waiting(expected_version) and returns: active_version