async def test_progress_ready_hook_async_func_exception(request, app):
    """Test progress ready hook in Spawner class with an exception in
    an async function
    """
    db = app.db
    name = 'saga'
    app_user = add_user(db, app=app, name=name)
    html_message = f'Server ready at <a href="{app_user.url}">{app_user.url}</a>'
    spawner = app_user.spawner

    async def custom_progress_ready_hook(spawner, ready_event):
        ready_event["html_message"] = "."
        raise Exception()

    spawner.progress_ready_hook = custom_progress_ready_hook
    r = await api_request(app, 'users', name, 'server', method='post')
    r.raise_for_status()
    r = await api_request(app, 'users', name, 'server/progress', stream=True)
    r.raise_for_status()
    request.addfinalizer(r.close)
    assert r.headers['content-type'] == 'text/event-stream'
    ex = async_requests.executor
    line_iter = iter(r.iter_lines(decode_unicode=True))
    evt = await ex.submit(next_event, line_iter)
    assert evt['progress'] == 100
    assert evt['ready']
    assert evt['url'] == app_user.url
    assert evt['html_message'] == html_message
Test progress ready hook in Spawner class with an exception in
an async function
jupyterhub/tests/test_api.py