исправленная версия с dlq
This commit is contained in:
+1
-12
@@ -9,8 +9,7 @@ from fastapi.responses import JSONResponse
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from starlette.exceptions import HTTPException as StarletteHTTPException
|
||||
from app.routers import auth, chats, attachments
|
||||
from app.database import AsyncSessionLocal
|
||||
from app.broker import relay_outbox
|
||||
from app.broker import run_relay
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -22,16 +21,6 @@ async def lifespan(app: FastAPI):
|
||||
# Останавливаем при завершении
|
||||
task.cancel()
|
||||
|
||||
async def run_relay():
|
||||
while True:
|
||||
try:
|
||||
async with AsyncSessionLocal() as db:
|
||||
await relay_outbox(db)
|
||||
await asyncio.sleep(1) # Проверяем outbox каждую секунду
|
||||
except Exception as e:
|
||||
logger.error(f"Relay loop crashed: {e}")
|
||||
await asyncio.sleep(5)
|
||||
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
|
||||
app.include_router(auth.router)
|
||||
|
||||
Reference in New Issue
Block a user