code: def serve():
      server_address = ("", port)
      httpd = HTTPServer(server_address, HTTPTestHandler)
      th = threading.Thread(target=httpd.serve_forever)
      th.daemon = True
      th.start()
      try:
          yield "http://localhost:%i" % port
      finally:
          httpd.socket.close()
          httpd.shutdown()
          th.join()
  
file_path: ray/python/ray/data/tests/mock_http_server.py
imports: import contextlib
  import threading
  from http.server import BaseHTTPRequestHandler, HTTPServer
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: serve() without return types