code: def test_worker_restart(serve_instance):
      @serve.deployment(name="worker_failure")
      class Worker1:
          def __call__(self, *args):
              return os.getpid()
  
      serve.run(Worker1.bind())
  
      # Get the PID of the worker.
      old_pid = request_with_retries("/worker_failure/", timeout=1).text
  
      # Kill the worker.
      handles = _get_worker_handles("worker_failure")
      assert len(handles) == 1
      ray.kill(handles[0], no_restart=False)
  
      # Wait until the worker is killed and a one is started.
      start = time.time()
      while time.time() - start < 30:
          response = request_with_retries(
              "/worker_failure/", timeout=30
          )
          if response.text != old_pid:
              break
      else:
          assert False, "Timed out waiting for worker to die."
  
file_path: ray/python/ray/serve/tests/test_failure.py
imports: import os
  import sys
  import time
  import pytest
  import requests
  import ray
  from ray import serve
  from ray._private.test_utils import SignalActor, wait_for_condition
  from ray.serve._private.common import DeploymentID
  from ray.serve._private.constants import SERVE_DEFAULT_APP_NAME
label_desc: Use image node_id 6 for calling a global function with example usage: test_worker_restart(serve_instance) and returns: os