Skip to content

Commit

Permalink
Merge branch 'staging' into update-vrs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Aug 5, 2024
2 parents 488f25c + f27e3b8 commit a2bbf33
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions server/src/curfu/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Provide FastAPI application and route declarations."""

from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager

from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
Expand Down Expand Up @@ -124,15 +127,15 @@ def get_domain_services() -> DomainService:
return domain_service


@app.on_event("startup")
async def startup() -> None:
"""Get FUSOR reference"""
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncGenerator:
"""Configure FastAPI instance lifespan.
:param app: FastAPI app instance
:return: async context handler
"""
app.state.fusor = await start_fusor()
app.state.genes = get_gene_services()
app.state.domains = get_domain_services()


@app.on_event("shutdown")
async def shutdown() -> None:
"""Clean up thread pool."""
yield
await app.state.fusor.cool_seq_tool.uta_db._connection_pool.close() # noqa: SLF001

0 comments on commit a2bbf33

Please sign in to comment.