code: def start_browser_when_ready(host, port=None, cancel_event=None):
      
      browser_thread = Thread(
          target=wait_and_start_browser, args=(host, port, cancel_event))
      browser_thread.daemon = True
      browser_thread.start()
      return browser_thread
docs: Starts a thread that waits for the server then opens the specified
      address in the browser. Set cancel_event to cancel the wait. The
      started thread object is returned.