ray.rllib.env.env_runner_group.EnvRunnerGroup.foreach_worker#

EnvRunnerGroup.foreach_worker(func: Callable[[EnvRunner], T], *, local_env_runner: bool = True, healthy_only: bool = True, remote_worker_ids: List[int] = None, timeout_seconds: float | None = None, return_obj_refs: bool = False, mark_healthy: bool = False, local_worker=-1) List[T][source]#

Calls the given function with each EnvRunner as its argument.

Parameters:
  • func – The function to call for each worker (as only arg).

  • local_env_runner – Whether to apply func to local EnvRunner, too. Default is True.

  • healthy_only – Apply func on known-to-be healthy workers only.

  • remote_worker_ids – Apply func on a selected set of remote workers. Use None (default) for all remote EnvRunners.

  • timeout_seconds – Time to wait (in seconds) for results. Set this to 0.0 for fire-and-forget. Set this to None (default) to wait infinitely (i.e. for synchronous execution).

  • return_obj_refs – whether to return ObjectRef instead of actual results. Note, for fault tolerance reasons, these returned ObjectRefs should never be resolved with ray.get() outside of this EnvRunnerGroup.

  • mark_healthy – Whether to mark all those workers healthy again that are currently marked unhealthy AND that returned results from the remote call (within the given timeout_seconds). Note that workers are NOT set unhealthy, if they simply time out (only if they return a RayActorError). Also note that this setting is ignored if healthy_only=True (b/c mark_healthy only affects workers that are currently tagged as unhealthy).

Returns:

The list of return values of all calls to func([worker]).

DeveloperAPI: This API may change across minor Ray releases.