Dotty Dotter
|
289d37a84b
|
#95 Job-Queue: SQLite-backed asyncio Worker mit Backpressure
FIFO-Queue für Analyse-Jobs — ersetzt FastAPI BackgroundTasks:
app/queue.py:
- asyncio.Queue mit MAX_QUEUE_SIZE=50
- Einzelner Worker-Coroutine (Concurrency=1, DashScope-freundlich)
- MIN_PAUSE_SECONDS=10 zwischen Jobs
- Exponentielles Backoff bei Serien-Fehlern (15s → 5min)
- get_queue_status() für den Status-Endpoint
- QueueFullError → HTTP 429 + Retry-After Header
- start_worker() als FastAPI-Startup-Task
- re_enqueue_pending() markiert Crash-Überlebende als 'stale'
main.py:
- POST /api/analyze-drucksache nutzt queue.enqueue() statt
background_tasks.add_task()
- Response enthält queue_position
- GET /api/queue/status zeigt pending, max_size, processed,
estimated_wait_seconds, worker_running
- Worker wird bei app.startup() gestartet
Tests: 201 passed, 5 skipped.
Refs: #95, #44 (Batch baut auf Queue auf)
|
2026-04-10 17:24:34 +02:00 |
|