code: def test_reconstruction_retry_failed(ray_start_cluster, failure_type):
      """Test the streaming generator retry fails in the second retry."""
      cluster = ray_start_cluster
      # Head node with no resources.
      cluster.add_node(
          num_cpus=0,
          _system_config=RECONSTRUCTION_CONFIG,
          enable_object_reconstruction=True,
      )
      ray.init(address=cluster.address)
  
      @ray.remote(num_cpus=0)
      class SignalActor:
          def __init__(self):
              self.crash = False
  
          def set(self):
              self.crash = True
  
          def get(self):
              return self.crash
  
      signal = SignalActor.remote()
      ray.get(signal.get.remote())
  
      # Node to place the initial object.
      node_to_kill = cluster.add_node(
          num_cpus=1, object_store_memory=10**8
      )
      cluster.wait_for_nodes()
  
      @ray.remote
      def dynamic_generator(num_returns, signal_actor):
          for i in range(num_returns):
              if i == 3:
                  should_crash = ray.get(signal_actor.get.remote())
                  if should_crash:
                      if failure_type == "exception":
                          raise Exception
                      else:
                          sys.exit(5)
              time.sleep(1)
              yield np.ones(1_000_000, dtype=np.int8) * i
  
      @ray.remote
      def fetch(x):
          return x[0]
  
      gen = dynamic_generator.remote(10, signal)
      refs = []
  
      for i in range(5):
          refs.append(next(gen))
  
      cluster.remove_node(node_to_kill, allow_graceful=False)
      node_to_kill = cluster.add_node(
          num_cpus=1, object_store_memory=10**8
      )
  
      for i, ref in enumerate(refs):
          print("first trial.")
          print("fetching ", i)
          assert ray.get(fetch.remote(ref)) == i
  
      # Try second retry.
      cluster.remove_node(node_to_kill, allow_graceful=False)
      node_to_kill = cluster.add_node(
          num_cpus=1, object_store_memory=10**8
      )
  
      signal.set.remote()
  
      for ref in gen:
          refs.append(ref)
  
      for i, ref in enumerate(refs):
          print("second trial")
          print("fetching ", i)
          print(ref)
          if i < 3:
              assert ray.get(fetch.remote(ref)) == i
          else:
              with pytest.raises(ray.exceptions.RayTaskError) as e:
                  assert ray.get(fetch.remote(ref)) == i
                  assert "The worker died" in str(e.value)
  
file_path: ray/python/ray/tests/test_streaming_generator_2.py
imports: import asyncio
  import pytest
  import numpy
  import sys
  import time
  import gc
  import ray
  from ray.experimental.state.api import list_actors
label_desc: Use image node_id 3 for calling a global function with example usage: test_reconstruction_retry_failed(ray_start_cluster, failure_type) and returns: x, self