code: def test_request_hangs_in_execution(ray_instance, shutdown_serve):
      """
      Verify that requests are timed out if they take longer than the timeout to execute.
      """
  
      @ray.remote
      class PidTracker:
          def __init__(self):
              self.pids = set()
  
          def add_pid(self, pid: int) -> None:
              self.pids.add(pid)
  
          def get_pids(self) -> Set[int]:
              return self.pids
  
      pid_tracker = PidTracker.remote()
      signal_actor = SignalActor.remote()
  
      @serve.deployment(num_replicas=2, graceful_shutdown_timeout_s=0)
      class HangsOnFirstRequest:
          def __init__(self):
              self._saw_first_request = False
  
          async def __call__(self):
              ray.get(pid_tracker.add_pid.remote(os.getpid()))
              if not self._saw_first_request:
                  self._saw_first_request = True
                  await asyncio.sleep(10)
  
              return "Success!"
  
      serve.run(HangsOnFirstRequest.bind())
  
      response = requests.get("http://localhost:8000")
      assert response.status_code == 408
  
      ray.get(signal_actor.send.remote())
  
imports: import asyncio
  import os
  import sys
  import time
  from typing import Generator, Set
  import pytest
  import requests
  from fastapi import FastAPI
  from starlette.requests import Request
  from starlette.responses import StreamingResponse
  import ray
  from ray import serve
  from ray._private.test_utils import SignalActor, wait_for_condition
  from ray.dashboard.modules.serve.sdk import ServeSubmissionClient
  from ray.serve._private.common import ApplicationStatus
  from ray.serve._private.test_utils import send_signal_on_cancellation
  from ray.serve.schema import ServeInstanceDetails
  from ray.util.state import list_tasks
label_desc: Use image node_id 4 for calling a global function with example usage: test_request_hangs_in_execution(ray_instance, shutdown_serve) and returns: self, str