ray.rllib.env.env_runner_group.EnvRunnerGroup.foreach_worker_async#

EnvRunnerGroup.foreach_worker_async(func: Callable[[EnvRunner], T], *, healthy_only: bool = True, remote_worker_ids: List[int] = None) int[source]#

Calls the given function asynchronously with each worker as the argument.

foreach_worker_async() does not return results directly. Instead, fetch_ready_async_reqs() can be used to pull results in an async manner whenever they are available.

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

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

  • remote_worker_ids – Apply func on a selected set of remote workers.

Returns:

The number of async requests that have actually been made. This is the length of remote_worker_ids (or self.num_remote_workers()` if remote_worker_ids is None) minus the number of requests that were NOT made b/c a remote worker already had its max_remote_requests_in_flight_per_actor counter reached.

DeveloperAPI: This API may change across minor Ray releases.