class_docstr: Internal proxy server handler class.
class_docstr_tok: ["Internal","proxy","server","handler","class","."]
docstr: Update information on tracker.
docstr_tok: ["Update","information","on","tracker","."]
code: def _update_tracker(self, period_update=False):
      """Update information on tracker."""
      try:
          if self._tracker_conn is None:
              self._tracker_conn = socket.socket(
                  base.get_addr_family(self._tracker_addr),
                  socket.SOCK_STREAM,
              )
              self._tracker_conn.connect(self._tracker_addr)
              self._tracker_conn.sendall(
                  struct.pack("<i", base.RPC_TRACKER_MAGIC)
              )
              magic = struct.unpack(
                  "<i", base.recvall(self._tracker_conn, 4)
              )[0]
              if magic != base.RPC_TRACKER_MAGIC:
                  self.loop.stop()
                  raise RuntimeError(
                      f"{self._tracker_addr} is not RPC Tracker"
                  )
              # just connect to tracker, need to update all keys
              self._tracker_pending_puts = self._server_pool.keys()
  
          if self._tracker_conn and period_update:
              # periodically update tracker information
              # regenerate key if the key is not in tracker anymore
              # and there is no in-coming connection after timeout_alloc
              base.sendjson(
                  self._tracker_conn,
                  [TrackerCode.GET_PENDING_MATCHKEYS],
              )
              pending_keys = set(base.recvjson(self._tracker_conn))
              update_keys = []
              for k, v in self._server_pool.items():
                  if k not in pending_keys:
                      if v.alloc_time is None:
                          v.alloc_time = time.time()
                      elif (
                          time.time() - v.alloc_time
                          > self.timeout_alloc
                      ):
                          update_keys.append(k)
                          v.alloc_time = None
              if update_keys:
                  logging.info(
                      "RPCProxy: No incoming conn on %s, regenerate keys...",
                      str(update_keys),
                  )
                  new_keys = self._regenerate_server_keys(update_keys)
                  self._tracker_pending_puts += new_keys
  
          need_update_info = False
          # report new connections
          for key in self._tracker_pending_puts:
              rpc_key, _ = base.split_random_key(key)
              base.sendjson(
                  self._tracker_conn,
                  [
                      TrackerCode.PUT,
                      rpc_key,
                      (self._listen_port, key),
                      None,
                  ],
              )
              assert (
                  base.recvjson(self._tracker_conn)
                  == TrackerCode.SUCCESS
              )
              if rpc_key not in self._key_set:
                  self._key_set.add(rpc_key)
                  need_update_info = True
  
          if need_update_info:
              keylist = "[" + ",".join(self._key_set) + "]"
              cinfo = {
                  "key": "server:proxy" + keylist,
                  "addr": [None, self._listen_port],
              }
              base.sendjson(
                  self._tracker_conn, [TrackerCode.UPDATE_INFO, cinfo]
              )
              assert (
                  base.recvjson(self._tracker_conn)
                  == TrackerCode.SUCCESS
              )
          self._tracker_pending_puts = []
      except (socket.error, IOError) as err:
          logging.info(
              "Lost tracker connection: %s, try reconnect in %g sec",
              str(err),
              self.update_tracker_period,
          )
          self._tracker_conn.close()
          self._tracker_conn = None
          self._regenerate_server_keys(self._server_pool.keys())
  
      if period_update:
  
          def _callback():
              self._update_tracker(True)
  
          self.loop.call_later(self.update_tracker_period, _callback)
  
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 5 for calling the ProxyServerHandler obj's underlying member method code with example usage: obj._update_tracker(period_update) without return types