mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-06 04:19:26 +00:00
Fix lifespan example (#1893)
Thanks a lot for this amazing tool.
When adding a `lifespan_handler` to my server, it only works if the
handler is asynchronously. That is consistent with the
[tests](994f53fb04/tests/test_lifespan.py (L13))
but not the documentation. So this PR aims to correct the documentation
This commit is contained in:
committed by
GitHub
parent
b3dd9862a3
commit
ee399fbfe6
@@ -18,7 +18,7 @@ instance.
|
||||
from connexion import AsyncApp, ConnexionMiddleware, request
|
||||
|
||||
@contextlib.asynccontextmanager
|
||||
def lifespan_handler(app: ConnexionMiddleware) -> typing.AsyncIterator:
|
||||
async def lifespan_handler(app: ConnexionMiddleware) -> typing.AsyncIterator:
|
||||
"""Called at startup and shutdown, can yield state which will be available on the
|
||||
request."""
|
||||
client = Client()
|
||||
@@ -44,7 +44,7 @@ instance.
|
||||
from connexion import FlaskApp, ConnexionMiddleware, request
|
||||
|
||||
@contextlib.asynccontextmanager
|
||||
def lifespan_handler(app: ConnexionMiddleware) -> typing.AsyncIterator:
|
||||
async def lifespan_handler(app: ConnexionMiddleware) -> typing.AsyncIterator:
|
||||
"""Called at startup and shutdown, can yield state which will be available on the
|
||||
request."""
|
||||
client = Client()
|
||||
@@ -71,7 +71,7 @@ instance.
|
||||
from connexion import ConnexionMiddleware, request
|
||||
|
||||
@contextlib.asynccontextmanager
|
||||
def lifespan_handler(app: ConnexionMiddleware) -> typing.AsyncIterator:
|
||||
async def lifespan_handler(app: ConnexionMiddleware) -> typing.AsyncIterator:
|
||||
"""Called at startup and shutdown, can yield state which will be available on the
|
||||
request."""
|
||||
client = Client()
|
||||
@@ -106,4 +106,4 @@ context manager.
|
||||
|
||||
For more information, please refer to the `Starlette documentation`_.
|
||||
|
||||
.. _Starlette documentation: https://www.starlette.io/lifespan/
|
||||
.. _Starlette documentation: https://www.starlette.io/lifespan/
|
||||
|
||||
Reference in New Issue
Block a user