def start_browser_when_ready(host, port=None, cancel_event=None):
    """
    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.
    """
    browser_thread = Thread(
        target=wait_and_start_browser, args=(host, port, cancel_event))
    browser_thread.daemon = True
    browser_thread.start()
    return browser_thread
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.