Skip to content

Commit

Permalink
fix(pydiscordsh): added back the lifespan of the database.
Browse files Browse the repository at this point in the history
  • Loading branch information
h0lybyte committed Jan 8, 2025
1 parent 18a903d commit 66d1381
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion apps/pydiscordsh/main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
from fastapi import FastAPI, WebSocket
from pydiscordsh import Routes, CORS, TursoDatabase
from contextlib import asynccontextmanager

import logging

logger = logging.getLogger("uvicorn")

app = FastAPI()

@asynccontextmanager
async def lifespan(app: FastAPI):
logger.info("[DB]@PENDING")
await database.start_client()
yield
logger.info("[DB]@DISINT")
await database.stop_client()
logger.info("[DB]@STOPPING")

app = FastAPI(lifespan=lifespan)
routes = Routes(app, templates_dir="templates")
CORS(app)

database = TursoDatabase()


@app.get("/v1/db/start_client")
async def start_client():
return await database.start_client()
Expand Down

0 comments on commit 66d1381

Please sign in to comment.