Tweaked some comments

This commit is contained in:
Simon Willison 2026-09-01 09:23:41 -07:00
commit fc6c5ab92f
2 changed files with 2 additions and 10 deletions

View file

@ -670,11 +670,9 @@ def serve(
raise click.ClickException("--token can only be used with --get")
if get:
# Run async soundness checks before startup hooks, since invoke_startup
# now populates internal tables which requires querying each database
# --get means we don't run Uvicorn at all
run_sync(lambda: check_databases(ds))
# Run the "startup" plugin hooks
try:
run_sync(ds.invoke_startup)
except StartupError as e:
@ -709,8 +707,7 @@ def serve(
# on the loop (asyncio.create_task, Lock/Queue/Event objects, ...) is
# still alive when the server starts handling requests.
async def _serve_async():
# Run async soundness checks before startup hooks, since invoke_startup
# now populates internal tables which requires querying each database
# Populate internal catalog tables before invoke_startup
await check_databases(ds)
# Run the "startup" plugin hooks

View file

@ -127,11 +127,6 @@ def test_startup_error_fails_fast_before_port_binds(serve_with_plugins):
A "startup" plugin hook that raises StartupError must fail fast: print
the message, exit non-zero, and never accept a connection on the port -
the failure must happen before uvicorn.Server binds the socket.
Note this is a characterization test, not a regression test: it also
passes on unmodified main, where startup already ran ahead of
uvicorn.run(). It earns its keep once startup moves into the ASGI
lifespan, where fail-fast is genuinely at risk.
"""
proc, port = serve_with_plugins(
{"startup_error_plugin": STARTUP_ERROR_PLUGIN}, wait_for_startup=False