class_docstr: Runtime to make sure that a server can asynchronously run inside a new asynchronous loop. It will make sure that the server is run forever while handling the TERMINATE signals
  to be received by the orchestrator to shutdown the server and its resources.
class_docstr_tok: ["Runtime","to","make","sure","that","a","server","can","asynchronously","run","inside","a","new","asynchronous","loop",".","It","will","make","sure","that","the","server","is","run","forever","while","handling","the","TERMINATE","signals","to","be","received","by","the","orchestrator","to","shutdown","the","server","and","its","resources","."]
code: def _get_server(self):
      # construct server type based on protocol (and potentially req handler class to keep backwards compatibility)
      from jina.enums import ProtocolType, ProviderType
  
      if self.req_handler_cls.__name__ == "GatewayRequestHandler":
          self.timeout_send = self.args.timeout_send
          if self.timeout_send:
              self.timeout_send /= 1e3  # convert ms to seconds
          if not self.args.port:
              self.args.port = random_ports(len(self.args.protocol))
          _set_gateway_uses(
              self.args,
              gateway_load_balancer=self.gateway_load_balancer,
          )
          uses_with = self.args.uses_with or {}
          non_defaults = ArgNamespace.get_non_defaults_args(
              self.args, set_gateway_parser()
          )
          if "title" not in non_defaults:
              uses_with["title"] = self.args.title
          if "description" not in non_defaults:
              uses_with["description"] = self.args.description
          if "no_debug_endpoints" not in non_defaults:
              uses_with[
                  "no_debug_endpoints"
              ] = self.args.no_debug_endpoints
          if "no_crud_endpoints" not in non_defaults:
              uses_with[
                  "no_crud_endpoints"
              ] = self.args.no_crud_endpoints
          if "expose_endpoints" not in non_defaults:
              uses_with["expose_endpoints"] = self.args.expose_endpoints
          if "expose_graphql_endpoint" not in non_defaults:
              uses_with[
                  "expose_graphql_endpoint"
              ] = self.args.expose_graphql_endpoint
          if "cors" not in non_defaults:
              uses_with["cors"] = self.args.cors
          server = BaseGateway.load_config(
              self.args.uses,
              uses_with=dict(
                  **non_defaults,
                  **uses_with,
              ),
              uses_metas={},
              runtime_args={  # these are not parsed to the yaml config file but are pass directly during init
                  **vars(self.args),
                  "default_port": getattr(
                      self.args, "default_port", False
                  ),
                  "gateway_load_balancer": self.gateway_load_balancer,
                  "timeout_send": self.timeout_send,
              },
              py_modules=self.args.py_modules,
              extra_search_paths=self.args.extra_search_paths,
          )
          if isinstance(server, BaseServer):
              server.is_cancel = self.is_cancel
          return server
      elif (
          hasattr(self.args, "provider")
          and self.args.provider == ProviderType.SAGEMAKER
      ):
          from jina.serve.runtimes.servers.http import (
              SagemakerHTTPServer,
          )
  
          return SagemakerHTTPServer(
              name=self.args.name,
              runtime_args=self.args,
              req_handler_cls=self.req_handler_cls,
              proxy=getattr(self.args, "proxy", None),
              uvicorn_kwargs=getattr(self.args, "uvicorn_kwargs", None),
              ssl_keyfile=getattr(self.args, "ssl_keyfile", None),
              ssl_certfile=getattr(self.args, "ssl_certfile", None),
              cors=getattr(self.args, "cors", None),
              is_cancel=self.is_cancel,
          )
      elif not hasattr(self.args, "protocol") or (
          len(self.args.protocol) == 1
          and self.args.protocol[0] == ProtocolType.GRPC
      ):
          from jina.serve.runtimes.servers.grpc import GRPCServer
  
          return GRPCServer(
              name=self.args.name,
              runtime_args=self.args,
              req_handler_cls=self.req_handler_cls,
              grpc_server_options=self.args.grpc_server_options,
              ssl_keyfile=getattr(self.args, "ssl_keyfile", None),
              ssl_certfile=getattr(self.args, "ssl_certfile", None),
              proxy=getattr(self.args, "proxy", None),
          )
  
      elif (
          len(self.args.protocol) == 1
          and self.args.protocol[0] == ProtocolType.HTTP
      ):
          from jina.serve.runtimes.servers.http import (
              HTTPServer,  # we need a concrete implementation of this
          )
  
          return HTTPServer(
              name=self.args.name,
              runtime_args=self.args,
              req_handler_cls=self.req_handler_cls,
              proxy=getattr(self.args, "proxy", None),
              uvicorn_kwargs=getattr(self.args, "uvicorn_kwargs", None),
              ssl_keyfile=getattr(self.args, "ssl_keyfile", None),
              ssl_certfile=getattr(self.args, "ssl_certfile", None),
              cors=getattr(self.args, "cors", None),
              is_cancel=self.is_cancel,
          )
      elif (
          len(self.args.protocol) == 1
          and self.args.protocol[0] == ProtocolType.WEBSOCKET
      ):
          from jina.serve.runtimes.servers.websocket import (
              WebSocketServer,  # we need a concrete implementation of this
          )
  
          return WebSocketServer(
              name=self.args.name,
              runtime_args=self.args,
              req_handler_cls=self.req_handler_cls,
              proxy=getattr(self.args, "proxy", None),
              uvicorn_kwargs=getattr(self.args, "uvicorn_kwargs", None),
              ssl_keyfile=getattr(self.args, "ssl_keyfile", None),
              ssl_certfile=getattr(self.args, "ssl_certfile", None),
              is_cancel=self.is_cancel,
          )
      elif len(self.args.protocol) > 1:
          from jina.serve.runtimes.servers.composite import (
              CompositeServer,  # we need a concrete implementation of this
          )
  
          return CompositeServer(
              name=self.args.name,
              runtime_args=self.args,
              req_handler_cls=self.req_handler_cls,
              ssl_keyfile=getattr(self.args, "ssl_keyfile", None),
              ssl_certfile=getattr(self.args, "ssl_certfile", None),
              is_cancel=self.is_cancel,
          )
  
imports: import argparse
  import asyncio
  import signal
  import time
  from typing import TYPE_CHECKING, Optional, Union
  from jina.constants import __windows__
  from jina.excepts import PortAlreadyUsed, RuntimeTerminated
  from jina.helper import ArgNamespace, is_port_free, random_ports, send_telemetry_event
  from jina.logging.logger import JinaLogger
  from jina.parsers import set_gateway_parser
  from jina.parsers.helper import _set_gateway_uses
  from jina.serve.runtimes.gateway.composite import CompositeGateway
  from jina.serve.runtimes.gateway.gateway import BaseGateway
  from jina.serve.runtimes.gateway.grpc import GRPCGateway
  from jina.serve.runtimes.gateway.http import HTTPGateway
  from jina.serve.runtimes.gateway.websocket import WebSocketGateway
  from jina.serve.runtimes.servers import BaseServer
label_desc: Use image node_id 5 for calling the AsyncNewLoopRuntime obj's underlying member method code with example usage: obj._get_server() and returns: server, SagemakerHTTPServer, GRPCServer, HTTPServer, WebSocketServer, CompositeServer