Skip to content

Commit

Permalink
fix startup
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Mar 16, 2024
1 parent eaa0064 commit 2d40cc3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions cashu/mint/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
from contextlib import asynccontextmanager
from traceback import print_exception

from fastapi import FastAPI, status
Expand All @@ -23,13 +22,14 @@

from .middleware import add_middlewares, request_validation_exception_handler


@asynccontextmanager
async def lifespan(app: FastAPI):
# startup routines here
await start_mint_init()
yield
# shutdown routines here
# this errors with the tests but is the appropriate way to handle startup and shutdown
# until then, we use @app.on_event("startup")
# @asynccontextmanager
# async def lifespan(app: FastAPI):
# # startup routines here
# await start_mint_init()
# yield
# # shutdown routines here


def create_app(config_object="core.settings") -> FastAPI:
Expand Down Expand Up @@ -98,3 +98,8 @@ async def catch_exceptions(request: Request, call_next):
else:
app.include_router(router=router, tags=["Mint"])
app.include_router(router=router_deprecated, tags=["Deprecated"], deprecated=True)


@app.on_event("startup")
async def startup_mint():
await start_mint_init()

0 comments on commit 2d40cc3

Please sign in to comment.