Repository navigation
Conversation
…lifespan protocol
Member
|
No, because obvious DoS vulnerability and broken handling of thread-locals and blocking route handlers or plugins. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a zero-dependency, native ASGI 3.0 Interface Adapter (
ASGIAdapter) to Bottle with support for:async defcoroutine routes and returned awaitable objects alongside standard synchronous routes.lifespan.startup,lifespan.shutdown) with corresponding application hooks (asgi_startup,asgi_shutdown).app.to_asgi()andapp.asgiproperty for direct mounting in ASGI servers (Uvicorn, Hypercorn, Granian).UvicornServerserver adapter inserver_names(run(app, server='uvicorn')).Motivation
While WSGI is battle-tested, modern Python server infrastructure increasingly runs on ASGI-native servers (such as Uvicorn, Hypercorn, Granian) and async ecosystems. Adding a native, zero-dependency ASGI 3.0 adapter allows developers to deploy Bottle applications directly on modern ASGI servers and mix
async defroute handlers without requiring third-party WSGI-to-ASGI wrapper packages.Key Additions
ASGIAdapter: Converts ASGI scopes (http,lifespan,websocket) and receive/send streams to Bottle's dispatch pipeline.Bottle.asgi/Bottle.to_asgi(): Directly exposes the ASGI entry point on anyBottleapplication instance.UvicornServer: Registered inserver_names['uvicorn']for easyrun(server='uvicorn')execution.'asgi_startup'and'asgi_shutdown'lifecycle hooks toBottle.Verification
test/test_asgi.pywith 9 comprehensive tests:async def)python -m unittest discover -t . -s test) — all 387 tests passing.