From fc6c5ab92fc20690024746f5103dde4899156ebc Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 1 Sep 2026 09:23:41 -0700 Subject: [PATCH] Tweaked some comments --- datasette/cli.py | 7 ++----- tests/test_cli_serve_server.py | 5 ----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/datasette/cli.py b/datasette/cli.py index 06fa6199..12024a14 100644 --- a/datasette/cli.py +++ b/datasette/cli.py @@ -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 diff --git a/tests/test_cli_serve_server.py b/tests/test_cli_serve_server.py index 2f113ded..b76180fd 100644 --- a/tests/test_cli_serve_server.py +++ b/tests/test_cli_serve_server.py @@ -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