class_docstr: Hexagon Launcher for Hexagon simulator.
class_docstr_tok: ["Hexagon","Launcher","for","Hexagon","simulator","."]
docstr: Abstract method implementation. See description in HexagonLauncherRPC.
docstr_tok: ["Abstract","method","implementation",".","See","description","in","HexagonLauncherRPC","."]
code: def start_server(self):
      """Abstract method implementation. See description in HexagonLauncherRPC."""
      # Copy binaries
      lib_dir = _get_hexagon_rpc_lib_dir()
      for item in self.SIMULATOR_HEXAGON_RPC_FILES:
          self._copy_to_remote(lib_dir / item, self._workspace / item)
      # Copy libc++ from the toolchain to the workspace
      self._copy_libcxx(self._workspace)
      self._rpc_info["device_key"] = (
          HEXAGON_REMOTE_DEVICE_KEY + "." + str(os.getpid())
      )
  
      rpc_tracker_host = self._rpc_info["rpc_tracker_host"]
      rpc_tracker_port = self._rpc_info["rpc_tracker_port"]
      rpc_server_port = self._rpc_info["rpc_server_port"]
      device_key = self._rpc_info["device_key"]
      server_exe = os.path.join(".", "tvm_rpc_x86")
  
      args = [
          "server",
          f"--tracker={rpc_tracker_host}:{rpc_tracker_port}",
          f"--port={rpc_server_port}",
          f"--key={device_key}",
          "--timeout=0",
      ]
  
      # pylint: disable=unused-argument
      def _terminate_handler(self, signum, *rest):
          # Terminate the Popen'ed (sub)process.
          os.kill(self._subprocess_pid, signal.SIGTERM)
  
      def _start(self):
          # This function will be running in a new process. It will start the RPC
          # (x86) server as a subprocess of itself.
          log_out = self._workspace / "stdout.txt"
          log_err = self._workspace / "stderr.txt"
          # Intercept the TERM signal so we can also terminate the subprocess.
          signal.signal(
              signal.SIGTERM, lambda *a: _terminate_handler(self, *a)
          )
  
          with open(log_out, "w") as out, open(log_err, "w") as err:
              p = subprocess.Popen(
                  [server_exe, *args],
                  stdout=out,
                  stderr=err,
                  cwd=self._workspace,
              )
              # Insert the pid of the subprocess in the self object.
              self._subprocess_pid = p.pid
              p.wait()
  
      self._server_process = mp.Process(
          target=lambda *a: _start(self, *a)
      )
      self._server_process.start()
  
imports: import abc
  import datetime
  import logging
  import multiprocessing
  import os
  import pathlib
  import signal
  import socket
  import stat
  import random
  import string
  import subprocess
  import sys
  import tempfile
  from typing import Union
  from tvm.contrib.hexagon.hexagon_profiler import HexagonProfiler
  from ..._ffi import libinfo
  from .session import Session
  from .tools import HEXAGON_SIMULATOR_NAME
label_desc: Use image node_id 5 for calling the HexagonLauncherSimulator obj's underlying member method code with example usage: obj.start_server() without return types