class_docstr: Internal PopenProxy State for Popen
class_docstr_tok: ["Internal","PopenProxy","State","for","Popen"]
code: def __init__(
      self,
      host,
      port=9091,
      port_end=9199,
      web_port=0,
      timeout_client=600,
      timeout_server=600,
      tracker_addr=None,
      index_page=None,
      resource_files=None,
  ):
      sock = socket.socket(
          base.get_addr_family((host, port)), socket.SOCK_STREAM
      )
      self.port = None
      for my_port in range(port, port_end):
          try:
              sock.bind((host, my_port))
              self.port = my_port
              break
          except socket.error as sock_err:
              if sock_err.errno in [errno.EADDRINUSE]:
                  continue
              raise sock_err
      if not self.port:
          raise ValueError(
              f"cannot bind to any port in [{port}, {port_end})"
          )
      logging.info(
          "RPCProxy: client port bind to %s:%d", host, self.port
      )
      sock.listen(1)
      self.thread = threading.Thread(
          target=_proxy_server,
          args=(
              sock,
              self.port,
              web_port,
              timeout_client,
              timeout_server,
              tracker_addr,
              index_page,
              resource_files,
          ),
      )
      # start the server in a different thread
      # so we can return the port directly
      self.thread.start()
  
imports: import os
  import asyncio
  import logging
  import socket
  import threading
  import errno
  import struct
  import time
  from tvm.contrib.popen_pool import PopenWorker
  from .None import _ffi_api
  from .None import base
  from .base import TrackerCode
  from .server import _server_env
  from .._ffi.base import py_str
label_desc: Use image node_id 1 to create a new PopenProxyServerState object from inherited base classes: object with example: obj = PopenProxyServerState(host, port, port_end, web_port, timeout_client, timeout_server, tracker_addr, index_page, resource_files)