class_docstr: Utility class to operate on a fixed pool of actors.
  
  Arguments:
      actors: List of Ray actor handles to use in this pool.
  
  Examples:
      .. testcode::
  
          import ray
          from ray.util.actor_pool import ActorPool
  
          @ray.remote
          class Actor:
              def double(self, v):
                  return 2 * v
  
          a1, a2 = Actor.remote(), Actor.remote()
          pool = ActorPool([a1, a2])
          print(list(pool.map(lambda a, v: a.double.remote(v),
                              [1, 2, 3, 4])))
  
      .. testoutput::
  
          [2, 4, 6, 8]
class_docstr_tok: ["Utility","class","to","operate","on","a","fixed","pool","of","actors",".","Arguments",":","actors",":","List","of","Ray","actor","handles","to","use","in","this","pool",".","Examples",":","..","testcode",":",":","import","ray","from","ray.util.actor_pool","import","ActorPool","@","ray.remote","class","Actor",":","def","double","(","self",",","v",")",":","return","2","*","v","a1",",","a2","=","Actor.remote","(",")",",","Actor.remote","(",")","pool","=","ActorPool","(","[","a1",",","a2","]",")","print","(","list","(","pool.map","(","lambda","a",",","v",":","a.double.remote","(","v",")",",","[","1",",","2",",","3",",","4","]",")",")",")","..","testoutput",":",":","[","2",",","4",",","6",",","8","]"]
docstr: Returns the next pending result in order.
  
  This returns the next result produced by submit(), blocking for up to
  the specified timeout until it is available.
  
  Returns:
      The next result.
  
  Raises:
      TimeoutError if the timeout is reached.
  
  Examples:
      .. testcode::
  
          import ray
          from ray.util.actor_pool import ActorPool
  
          @ray.remote
          class Actor:
              def double(self, v):
                  return 2 * v
  
          a1, a2 = Actor.remote(), Actor.remote()
          pool = ActorPool([a1, a2])
          pool.submit(lambda a, v: a.double.remote(v), 1)
          print(pool.get_next())
  
      .. testoutput::
  
          2
docstr_tok: ["Returns","the","next","pending","result","in","order",".","This","returns","the","next","result","produced","by","submit","(",")",",","blocking","for","up","to","the","specified","timeout","until","it","is","available",".","Returns",":","The","next","result",".","Raises",":","TimeoutError","if","the","timeout","is","reached",".","Examples",":","..","testcode",":",":","import","ray","from","ray.util.actor_pool","import","ActorPool","@","ray.remote","class","Actor",":","def","double","(","self",",","v",")",":","return","2","*","v","a1",",","a2","=","Actor.remote","(",")",",","Actor.remote","(",")","pool","=","ActorPool","(","[","a1",",","a2","]",")","pool.submit","(","lambda","a",",","v",":","a.double.remote","(","v",")",",","1",")","print","(","pool.get_next","(",")",")","..","testoutput",":",":","2"]
code: def get_next(self, timeout=None, ignore_if_timedout=False):
      """Returns the next pending result in order.
  
      This returns the next result produced by submit(), blocking for up to
      the specified timeout until it is available.
  
      Returns:
          The next result.
  
      Raises:
          TimeoutError if the timeout is reached.
  
      Examples:
          .. testcode::
  
              import ray
              from ray.util.actor_pool import ActorPool
  
              @ray.remote
              class Actor:
                  def double(self, v):
                      return 2 * v
  
              a1, a2 = Actor.remote(), Actor.remote()
              pool = ActorPool([a1, a2])
              pool.submit(lambda a, v: a.double.remote(v), 1)
              print(pool.get_next())
  
          .. testoutput::
  
              2
      """
      if not self.has_next():
          raise StopIteration("No more results to get")
      if self._next_return_index >= self._next_task_index:
          raise ValueError(
              "It is not allowed to call get_next() after get_next_unordered()."
          )
      future = self._index_to_future[self._next_return_index]
      timeout_msg = "Timed out waiting for result"
      raise_timeout_after_ignore = False
      if timeout is not None:
          res, _ = ray.wait([future], timeout=timeout)
          if not res:
              if not ignore_if_timedout:
                  raise TimeoutError(timeout_msg)
              else:
                  raise_timeout_after_ignore = True
      del self._index_to_future[self._next_return_index]
      self._next_return_index += 1
  
      future_key = tuple(future) if isinstance(future, list) else future
      i, a = self._future_to_actor.pop(future_key)
  
      self._return_actor(a)
      if raise_timeout_after_ignore:
          raise TimeoutError(
              timeout_msg
              + ". The task {} has been ignored.".format(future)
          )
      return ray.get(future)
  
file_path: ray/python/ray/util/actor_pool.py
imports: from typing import TYPE_CHECKING, Any, Callable, List, TypeVar
  import ray
  from ray.util.annotations import DeveloperAPI
label_desc: Use image node_id 6 for calling the ActorPool obj's underlying member method code with example usage: obj.get_next(timeout, ignore_if_timedout) and returns: ray