code: def test_warning_for_too_many_actors(shutdown_only):
      # Check that if we run a workload which requires too many workers to be
      # started that we will receive a warning.
      num_cpus = 2
      ray.init(num_cpus=num_cpus)
  
      p = init_error_pubsub()
  
      @ray.remote(num_cpus=0)
      class Foo:
          def __init__(self):
              time.sleep(1000)
  
      # NOTE: We should save actor, otherwise it will be out of scope.
      actor_group1 = [Foo.remote() for _ in range(num_cpus * 10)]
      assert len(actor_group1) == num_cpus * 10
      errors = get_error_message(
          p, 1, ray_constants.WORKER_POOL_LARGE_ERROR
      )
      assert len(errors) == 1
      assert errors[0]["type"] == ray_constants.WORKER_POOL_LARGE_ERROR
  
      actor_group2 = [Foo.remote() for _ in range(num_cpus * 3)]
      assert len(actor_group2) == num_cpus * 3
      errors = get_error_message(
          p, 1, ray_constants.WORKER_POOL_LARGE_ERROR
      )
      assert len(errors) == 1
      assert errors[0]["type"] == ray_constants.WORKER_POOL_LARGE_ERROR
      p.close()
  
imports: import os
  import signal
  import sys
  import threading
  import time
  import numpy
  import pytest
  import ray
  import ray._private.ray_constants
  import ray._private.utils
  from ray._private.ray_constants import DEBUG_AUTOSCALING_ERROR
  from ray._private.test_utils import Semaphore, get_error_message, get_log_batch, init_error_pubsub, run_string_as_driver_nonblocking, wait_for_condition
  from ray.cluster_utils import cluster_not_supported
  from ray.experimental.internal_kv import _internal_kv_get
label_desc: Use image node_id 1 for calling a global function with example usage: test_warning_for_too_many_actors(shutdown_only) without return types