Skip to content

Commit

Permalink
Fix lifespan example (#1893)
Browse files Browse the repository at this point in the history
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](https://github.com/spec-first/connexion/blob/994f53fb045f1668ab84c472f7dc06d093470cf1/tests/test_lifespan.py#L13)
but not the documentation. So this PR aims to correct the documentation
  • Loading branch information
fcollonval authored Mar 20, 2024
1 parent b3dd986 commit ee399fb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/lifespan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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/

0 comments on commit ee399fb

Please sign in to comment.