class_docstr: State representation used for tracking in memory state across workers.
  
  Args:
      bcast_object: Function used to broadcast a variable from rank 0 to the other workers.
      get_rank: Function that returns the current rank of this worker.
class_docstr_tok: ["State","representation","used","for","tracking","in","memory","state","across","workers",".","Args",":","bcast_object",":","Function","used","to","broadcast","a","variable","from","rank","0","to","the","other","workers",".","get_rank",":","Function","that","returns","the","current","rank","of","this","worker","."]
docstr: Checks that a notification has been sent indicating that hosts can be added or will be removed.
  
  Raises a `HostsUpdatedInterrupt` if such a notification has been received.
docstr_tok: ["Checks","that","a","notification","has","been","sent","indicating","that","hosts","can","be","added","or","will","be","removed",".","Raises","a","`","HostsUpdatedInterrupt","`","if","such","a","notification","has","been","received","."]
code: def check_host_updates(self):
      """Checks that a notification has been sent indicating that hosts can be added or will be removed.
  
      Raises a `HostsUpdatedInterrupt` if such a notification has been received.
      """
      # Iterate through the update messages sent from the server. If the update timestamp
      # is greater than the last update timestamp, then trigger a HostsUpdatedException.
      last_updated_timestamp = (
          prev_timestamp
      ) = self._last_updated_timestamp
      all_update = HostUpdateResult.no_update
      while not self._host_messages.empty():
          timestamp, update = self._host_messages.get()
          if timestamp > last_updated_timestamp:
              last_updated_timestamp = timestamp
              all_update |= update
  
      # In order to ensure all workers raise the exception at the same time, we need to sync
      # the updated state across all the workers.
      # TODO(travis): this should be a max allreduce to account for changes in rank 0
      (
          prev_timestamp,
          self._last_updated_timestamp,
          all_update,
      ) = self._bcast_object(
          (prev_timestamp, last_updated_timestamp, all_update)
      )
  
      # At this point, updated state is globally consistent across all ranks.
      if self._last_updated_timestamp > prev_timestamp:
          raise HostsUpdatedInterrupt(
              all_update == HostUpdateResult.removed
          )
  
imports: import functools
  import queue
  from horovod.common.exceptions import HorovodInternalError, HostsUpdatedInterrupt
  from horovod.runner.elastic.worker import HostUpdateResult, WorkerNotificationManager
label_desc: Use image node_id 6 for calling the State obj's underlying member method code with example usage: obj.check_host_updates() without return types