Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Satisfy aiohttp's deprecation of shutdown timeout kwargs #1091

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kopf/_core/engines/probing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/test_liveness.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading