feat: advanced RW sync system

This commit is contained in:
2026-08-24 10:22:14 +07:00
parent b39cae8046
commit 8d1b753b99
12 changed files with 262 additions and 22 deletions

15
main.py
View File

@@ -5,17 +5,24 @@ from fastapi import FastAPI
from routes import routers
from services.notifications import run_subscription_notifications
from services.rw_sync import run_rw_sync_reconciler, run_rw_sync_worker
@asynccontextmanager
async def lifespan(_: FastAPI):
task = asyncio.create_task(run_subscription_notifications())
tasks = [
asyncio.create_task(run_subscription_notifications()),
asyncio.create_task(run_rw_sync_worker()),
asyncio.create_task(run_rw_sync_reconciler()),
]
try:
yield
finally:
task.cancel()
with suppress(asyncio.CancelledError):
await task
for task in tasks:
task.cancel()
for task in tasks:
with suppress(asyncio.CancelledError):
await task
app = FastAPI(debug=True, lifespan=lifespan)