feat: advanced RW sync system
This commit is contained in:
15
main.py
15
main.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user