Fix error page loop + account startup timeout
- Error handlers for FragmentError and generic Exception now return self-contained HTML (no render_template) to avoid the infinite loop where context processor → fetch_fragments → error → render_template → context processor → fetch_fragments → error ... - Account Ghost membership sync moved to background task so it doesn't block Hypercorn's startup timeout (was causing crash-loop). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -82,18 +82,22 @@ def create_app() -> "Quart":
|
||||
from bp.data.routes import register as register_data
|
||||
app.register_blueprint(register_data())
|
||||
|
||||
# --- Ghost membership sync at startup ---
|
||||
# --- Ghost membership sync at startup (background) ---
|
||||
# Runs as a background task to avoid blocking Hypercorn's startup timeout.
|
||||
@app.before_serving
|
||||
async def _sync_ghost_membership():
|
||||
from services.ghost_membership import sync_all_membership_from_ghost
|
||||
from shared.db.session import get_session
|
||||
try:
|
||||
async with get_session() as s:
|
||||
await sync_all_membership_from_ghost(s)
|
||||
await s.commit()
|
||||
print("[account] Ghost membership sync complete")
|
||||
except Exception as e:
|
||||
print(f"[account] Ghost membership sync failed (non-fatal): {e}")
|
||||
async def _schedule_ghost_membership_sync():
|
||||
import asyncio
|
||||
async def _sync():
|
||||
from services.ghost_membership import sync_all_membership_from_ghost
|
||||
from shared.db.session import get_session
|
||||
try:
|
||||
async with get_session() as s:
|
||||
await sync_all_membership_from_ghost(s)
|
||||
await s.commit()
|
||||
print("[account] Ghost membership sync complete")
|
||||
except Exception as e:
|
||||
print(f"[account] Ghost membership sync failed (non-fatal): {e}")
|
||||
asyncio.get_event_loop().create_task(_sync())
|
||||
|
||||
return app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user