mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2026-11-01 01:24:45 +03:00
feat: update codebase to use httpx2 and enhance docstrings for clarity
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
"""Background database health-check scheduling."""
|
||||
|
||||
from collections.abc import AsyncIterator
|
||||
from contextlib import asynccontextmanager
|
||||
from datetime import datetime
|
||||
@@ -15,7 +17,8 @@ from app.database import AsyncSessionFactory, engine
|
||||
logger = get_logger()
|
||||
|
||||
|
||||
async def tick():
|
||||
async def tick() -> bool:
|
||||
"""Run the scheduler's lightweight database heartbeat."""
|
||||
async with AsyncSessionFactory() as session:
|
||||
stmt = text("select 1;")
|
||||
await logger.ainfo(f">>>> Be or not to be...{datetime.now()}")
|
||||
@@ -26,6 +29,7 @@ async def tick():
|
||||
|
||||
@asynccontextmanager
|
||||
async def scheduler_lifespan() -> AsyncIterator[None]:
|
||||
"""Start the scheduler and stop it when the app lifespan ends."""
|
||||
scheduler = AsyncScheduler(
|
||||
SQLAlchemyDataStore(engine, schema="scheduler"),
|
||||
RedisEventBroker(client_or_url=global_settings.redis_url.unicode_string()),
|
||||
|
||||
Reference in New Issue
Block a user