diff --git a/tests/test_app.py b/tests/test_app.py index a8542c2..adf28da 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -286,24 +286,22 @@ def test_app_run(): async def set_running(): running.set() - app_thread = threading.Thread( - target=app.run, - kwargs=dict( - host="127.0.0.1", - port=8000, - debug=True, - limit_max_requests=1, # end after one request - callback_notify=set_running, - timeout_notify=1, # set the running event every second - ), - ) + def do_request(): + if not running.wait(10.0): + raise TimeoutError("App hasn't started after 10s") + + requests.get("http://127.0.0.1:8000") - app_thread.start() - if not running.wait(10.0): - raise TimeoutError("App hasn't started after 10s") + request_thread = threading.Thread(target=do_request) + request_thread.start() - requests.get("http://127.0.0.1:8000") + app.run( + host="127.0.0.1", + port=8000, + debug=True, + limit_max_requests=1, # end after one request + callback_notify=set_running, + timeout_notify=1, # set the running event every second + ) - app_thread.join(10.0) - if app_thread.is_alive(): - raise TimeoutError("App hasn't stoped after 10s") + request_thread.join()