Skip to content

fix: support Starlette 1.0 by using lifespan instead of on_startup/on_shutdown#1151

Open
maartenbreddelsai wants to merge 1 commit intowidgetti:masterfrom
maartenbreddelsai:fix/starlette-1.0-lifespan
Open

fix: support Starlette 1.0 by using lifespan instead of on_startup/on_shutdown#1151
maartenbreddelsai wants to merge 1 commit intowidgetti:masterfrom
maartenbreddelsai:fix/starlette-1.0-lifespan

Conversation

@maartenbreddelsai
Copy link
Copy Markdown

@maartenbreddelsai maartenbreddelsai commented Mar 13, 2026

Summary

Starlette 1.0 removed the on_startup and on_shutdown parameters from Starlette.__init__(). This causes Solara to crash on import with Starlette 1.0.

Fixes #1143

Changes

  • Add lifespan async context manager that wraps existing on_startup() and on_shutdown() functions
  • Use lifespan parameter instead of on_startup/on_shutdown
  • Add unit test for lifespan context manager

The lifespan parameter has been supported since Starlette 0.13.5, so this change is backward compatible with all reasonably recent Starlette versions.

Testing

Tested with both:

  • Starlette 0.52.1
  • Starlette 1.0.0rc1

@maartenbreddelsai maartenbreddelsai force-pushed the fix/starlette-1.0-lifespan branch from 6660785 to 8904774 Compare March 13, 2026 09:17
… compatibility

Starlette 1.0 removed the on_startup and on_shutdown parameters in favor
of the lifespan context manager. This change migrates to using lifespan,
which has been supported since Starlette 0.13.5.

Fixes widgetti#1143
@maartenbreddelsai maartenbreddelsai force-pushed the fix/starlette-1.0-lifespan branch from 8904774 to 5a7fde6 Compare March 13, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Starlette 1.0 breaks Solara import: Starlette.__init__() no longer accepts on_startup / on_shutdown

1 participant