fix: add timeouts to SSL/DNS blocking calls, reset stuck AI jobs on startup
- SSL handshake: set socket timeout before wrap_socket (prevents indefinite hang) - SSL executor: asyncio.wait_for(..., timeout=12) - DNS gethostbyname: asyncio.wait_for(..., timeout=6) - analyze_site: hard 90s timeout wrapper - _assess_one: hard 180s ceiling via asyncio.timeout() - ai_worker_loop: reset 'running' → 'pending' on startup (clears crashed-session jobs) - Add POST /api/ai/reset endpoint + UI button to unstick jobs without restart Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
11
app/main.py
11
app/main.py
@@ -184,6 +184,17 @@ async def ai_worker_restart():
|
||||
return {"status": "restarted"}
|
||||
|
||||
|
||||
@app.post("/api/ai/reset")
|
||||
async def ai_reset():
|
||||
"""Reset all 'running' AI queue jobs back to 'pending' (unstick hung jobs)."""
|
||||
async with aiosqlite.connect(SQLITE_PATH) as db:
|
||||
r = await db.execute("UPDATE ai_queue SET status='pending' WHERE status='running'")
|
||||
count = r.rowcount
|
||||
await db.commit()
|
||||
ensure_workers_alive()
|
||||
return {"reset": count}
|
||||
|
||||
|
||||
@app.get("/api/ai/debug")
|
||||
async def ai_debug():
|
||||
"""Returns worker state + last 10 queue entries for troubleshooting."""
|
||||
|
||||
Reference in New Issue
Block a user