diff --git a/kopf/_core/engines/probing.py b/kopf/_core/engines/probing.py index 0c1bbb99..fb7e7ece 100644 --- a/kopf/_core/engines/probing.py +++ b/kopf/_core/engines/probing.py @@ -79,10 +79,10 @@ async def get_health( app = aiohttp.web.Application() app.add_routes([aiohttp.web.get(path, get_health)]) - runner = aiohttp.web.AppRunner(app, handle_signals=False) + runner = aiohttp.web.AppRunner(app, handle_signals=False, shutdown_timeout=1.0) await runner.setup() - site = aiohttp.web.TCPSite(runner, host, port, shutdown_timeout=1.0) + site = aiohttp.web.TCPSite(runner, host, port) await site.start() # Log with the actual URL: normalised, with hostname/port set. diff --git a/requirements.txt b/requirements.txt index 65a2a83c..619d8e32 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ pre-commit pyngrok pytest>=6.0.0 pytest-aiohttp -pytest-asyncio +pytest-asyncio<0.22 # until the "event_loop" deprecation is solved pytest-cov pytest-mock pytest-timeout diff --git a/tests/test_liveness.py b/tests/test_liveness.py index 35cc578f..47cc8ead 100644 --- a/tests/test_liveness.py +++ b/tests/test_liveness.py @@ -34,8 +34,10 @@ async def liveness_url(settings, liveness_registry, unused_tcp_port_factory): ) ) + # Generally there is no or minimal timeout, except if the runner/server raise on start up. + # In that case, escalate their error from the task instead of hanging here forever. try: - await ready_flag.wait() + await asyncio.wait_for(ready_flag.wait(), timeout=1) yield f'http://localhost:{port}/xyz' finally: server.cancel()