code: def connect_with_retry(addr, timeout=60, retry_period=5):
      """Connect to a TPC address with retry
  
      This function is only reliable to short period of server restart.
  
      Parameters
      ----------
      addr : tuple
          address tuple
  
      timeout : float
           Timeout during retry
  
      retry_period : float
           Number of seconds before we retry again.
      """
      tstart = time.time()
      while True:
          try:
              sock = socket.socket(
                  get_addr_family(addr), socket.SOCK_STREAM
              )
              sock.connect(addr)
              return sock
          except socket.error as sock_err:
              if sock_err.args[0] not in (errno.ECONNREFUSED,):
                  raise sock_err
              period = time.time() - tstart
              if period > timeout:
                  raise RuntimeError(
                      f"Failed to connect to server {str(addr)}"
                  )
              logger.warning(
                  f"Cannot connect to tracker {str(addr)}, retry in {retry_period:g} secs..."
              )
              time.sleep(retry_period)
  
file_path: tvm/python/tvm/rpc/base.py
imports: import socket
  import time
  import json
  import errno
  import struct
  import random
  import logging
  from .._ffi.base import py_str
label_desc: Use image node_id 7 for calling a global function with example usage: connect_with_retry(addr, timeout, retry_period) and returns: sock