code: def wait_for_jupyter(addr):
      """
      Avoid logging enormous stacktraces when the requests library attempts to connect to a server
      that isn't accepting connections yet.  This is expected as jupyter startup time might take
      longer than a second, and we don't want to generate scary logs for expected behavior.
      """
      i = 0
      while True:
          with socket.socket() as s:
              try:
                  s.connect(addr)
                  # Connection worked, we're done here.
                  return
              except ConnectionError as e:
                  if (i + 1) % 10 == 0:
                      # Every 10 seconds without reaching jupyter, start telling the user.
                      # This is beyond the range of expected startup times.
                      logging.warning(
                          f"jupyter is still not reachable at {addr}"
                      )
              time.sleep(1)
              i += 1
  
file_path: determined/master/static/srv/check_idle.py
imports: import enum
  import logging
  import os
  import socket
  import time
  import requests
  from determined.common import api
  from determined.common.api import certs
label_desc: Use image node_id 1 for calling a global function with example usage: wait_for_jupyter(addr) without return types