Skip to content

Conversation

@grahamalama
Copy link
Contributor

@grahamalama grahamalama commented Feb 23, 2024

Some somewhat raw notes:

Using a client context manager for lifespan events: https://fastapi.tiangolo.com/advanced/testing-events/

Though the startup and shutdown events are deprecated, this seemed to work here

Also, I thought I'd need to do something like this, but I didn't 🤷🏻

@grahamalama grahamalama requested a review from a team as a code owner February 23, 2024 15:32

# https://github.com/tiangolo/fastapi/discussions/9241
@asynccontextmanager
async def lifespan(app: FastAPI): # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async def lifespan(app: FastAPI): # type: ignore
async def lifespan(app: FastAPI) -> AsyncIterator[None]:

Copy link
Contributor

@leplatrem leplatrem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it clean 💯
Thanks a lot!

There are a few details (eg. repeated with TestClient(app)) that I'll try to address in the target branch...

@leplatrem leplatrem merged commit 7e8eb86 into leverage-dockerflow-2024.2.0 Feb 23, 2024
@leplatrem leplatrem deleted the register-checks-in-lifespan branch February 23, 2024 17:12
leplatrem added a commit that referenced this pull request Mar 7, 2024
* Remove redundant code

* Set APP_DIR explicitly

Without this, the APP_DIR is `/app` which makes tests fail.

* python-dockerflow does not log querystrings (see mozilla-services/python-dockerflow#97)

* Include dockerflow submodules in overrides

* Include fastapi subdeps

* Reorder imports

* Register checks in lifespan (#878)

* Register checks in lifespan

* Add bugzilla checks

* Ignore lifespan type

* Add type to lifespan

* Prepare for new features of python-dockerflow

* Prepare for dockerflow-2024.3.0

* Revert "python-dockerflow does not log querystrings (see mozilla-services/python-dockerflow#97)"

This reverts commit fbfe9e3.

---------

Co-authored-by: grahamalama <gbeckley@mozilla.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants