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: Create new rendezvous state or raise an exception that indicates an unexpected state (e.g. already exists).
  
  Raises:
       RendezvousError - on unexpected state
docstr_tok: ["Create","new","rendezvous","state","or","raise","an","exception","that","indicates","an","unexpected","state","(","e.g",".","already","exists",")",".","Raises",":","RendezvousError","-","on","unexpected","state"]
code: def try_create_rendezvous(self):
      """
      Create new rendezvous state or raise an exception that indicates an unexpected state (e.g. already exists).
  
      Raises:
           RendezvousError - on unexpected state
      """
      # Initially active_version is ephemeral - this is to handle the
      # possibility that might fail to complete the setup transaction,
      # i.e. the transition "setup" -> "joinable".
      active_version = self.client.write(
          key=self.get_path("/rdzv/active_version"),
          value=json.dumps({"status": "setup"}),
          prevExist=False,
          ttl=CONST_ETCD_SETUP_TTL,
      )
  
      try:
          version_counter = self.client.get(
              self.get_path("/rdzv/version_counter")
          )
          version_counter.value = str(int(version_counter.value) + 1)
          self.client.update(version_counter)
      except (etcd.EtcdKeyNotFound, etcd.EtcdCompareFailed) as e:
          raise RendezvousError(
              "Unexpected state of EtcdRendezvousHandler, worker needs to die."
          ) from e
  
      # Any failure below results in declaring a retryable rendezvous failure.
      # The ephemeral /rdzv/active_version will expire and someone can then
      # re-try the setup process.
  
      # Create directory node for participant data
      self.client.write(
          key=self.get_path(f"/rdzv/v_{version_counter.value}"),
          value=None,
          dir=True,
          prevExist=False,
      )
  
      # Publish rendezvous version and signal it is ready-to-be-joined.
      # If rendezvous was set closed just before this, a retry will happen,
      # where the closed condition will be handled.
      return self.client.test_and_set(
          key=self.get_path("/rdzv/active_version"),
          value=json.dumps(
              {
                  "status": "joinable",
                  "version": version_counter.value,
                  "participants": [],
              }
          ),
          prev_value=active_version.value,
      )
  
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 8 for calling the EtcdRendezvous obj's underlying member method code with example usage: obj.try_create_rendezvous() and returns: self