class_docstr: A variable client for updating variables from a remote source.
class_docstr_tok: ["A","variable","client","for","updating","variables","from","a","remote","source","."]
docstr: Periodically updates the variables with the latest copy from the source.
  
  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.
  
  Args:
    wait: Whether to execute asynchronous (False) or blocking updates (True).
      Defaults to False.
docstr_tok: ["Periodically","updates","the","variables","with","the","latest","copy","from","the","source",".","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",".","Args",":","wait",":","Whether","to","execute","asynchronous","(","False",")","or","blocking","updates","(","True",")",".","Defaults","to","False","."]
code: def update(self, wait: bool = False) -> None:
      """Periodically updates the variables with the latest copy from the source.
  
      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.
  
      Args:
        wait: Whether to execute asynchronous (False) or blocking updates (True).
          Defaults to False.
      """
      # Track calls (we only update periodically).
      self._call_counter += 1
  
      # Return if it's not time to fetch another update.
      if isinstance(self._update_period, datetime.timedelta):
          if (
              self._update_period.total_seconds() + self._last_call
              > time.time()
          ):
              return
      else:
          if self._call_counter < self._update_period:
              return
  
      if wait:
          if self._future is not None:
              if self._future.running():
                  self._future.cancel()
              self._future = None
          self._call_counter = 0
          self._last_call = time.time()
          self.update_and_wait()
          return
  
      # Return early if we are still waiting for a previous request to come back.
      if self._future and not self._future.done():
          return
  
      # Get a future and add the copy function as a callback.
      self._call_counter = 0
      self._last_call = time.time()
      self._future = self._async_request()
      self._future.add_done_callback(
          lambda f: self._callback(f.result())
      )
  
file_path: acme/acme/jax/variable_utils.py
imports: from concurrent import futures
  import datetime
  import time
  from typing import List, NamedTuple, Optional, Sequence, Union
  from acme import core
  from acme.jax import networks
  import jax
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