class_docstr: A variable client for updating variables from a remote source.
docstr: Periodically updates the variables with the latest copy from the source.
  
  This stateful update method keeps track of the number of calls to it and,
  every `update_period` call, sends a request to its server to retrieve the
  latest variables.
  
  If wait is True, a blocking request is executed. Any active request will be
  cancelled.
  If wait is False, this method makes an asynchronous request for variables
  and returns. Unless the request is immediately fulfilled, the variables are
  only copied _within a subsequent call to_ `update()`, whenever the request
  is fulfilled by the `VariableSource`. If there is an existing fulfilled
  request when this method is called, the resulting variables are immediately
  copied.
  
  Args:
    wait: if True, executes blocking update.
code: def update(self, wait: bool = False):
      """Periodically updates the variables with the latest copy from the source.
  
      This stateful update method keeps track of the number of calls to it and,
      every `update_period` call, sends a request to its server to retrieve the
      latest variables.
  
      If wait is True, a blocking request is executed. Any active request will be
      cancelled.
      If wait is False, this method makes an asynchronous request for variables
      and returns. Unless the request is immediately fulfilled, the variables are
      only copied _within a subsequent call to_ `update()`, whenever the request
      is fulfilled by the `VariableSource`. If there is an existing fulfilled
      request when this method is called, the resulting variables are immediately
      copied.
  
      Args:
        wait: if True, executes blocking update.
      """
      # Track the number of calls (we only update periodically).
      if self._call_counter < self._update_period:
          self._call_counter += 1
  
      period_reached: bool = self._call_counter >= self._update_period
  
      if period_reached and wait:
          # Cancel any active request.
          self._future: Optional[futures.Future] = None
          self.update_and_wait()
          self._call_counter = 0
          return
  
      if period_reached and self._future is None:
          # The update period has been reached and no request has been sent yet, so
          # making an asynchronous request now.
          self._future = self._async_request()
          self._call_counter = 0
  
      if self._future is not None and self._future.done():
          # The active request is done so copy the result and remove the future.
          self._copy(self._future.result())
          self._future: Optional[futures.Future] = None
      else:
          # There is either a pending/running request or we're between update
          # periods, so just carry on.
          return
  
file_path: acme/acme/tf/variable_utils.py
imports: from concurrent import futures
  from typing import Mapping, Optional, Sequence
  from acme import core
  import tensorflow
  import tree
label_desc: Use image node_id 2 for calling the VariableClient obj's underlying member method code with example usage: obj.update(wait) without return types