Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -680,6 +680,23 @@ async def consume_loop():
|
|
| 680 |
except Exception as e:
|
| 681 |
logger.error(f"[KAFKA] analysis failed analysisId={analysis_id}: {repr(e)}", exc_info=True)
|
| 682 |
await produce_progress(analysis_id, user_id, 100, "ERROR", f"오류: {type(e).__name__}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 683 |
|
| 684 |
finally:
|
| 685 |
logger.info("[KAFKA] stopped")
|
|
|
|
| 680 |
except Exception as e:
|
| 681 |
logger.error(f"[KAFKA] analysis failed analysisId={analysis_id}: {repr(e)}", exc_info=True)
|
| 682 |
await produce_progress(analysis_id, user_id, 100, "ERROR", f"오류: {type(e).__name__}")
|
| 683 |
+
"에러 결과"로 반드시 보내기 (프론트 로딩 종료용)
|
| 684 |
+
if producer:
|
| 685 |
+
err_payload = {
|
| 686 |
+
"analysisId": analysis_id,
|
| 687 |
+
"userId": user_id,
|
| 688 |
+
"result": {
|
| 689 |
+
"error": True,
|
| 690 |
+
"message": f"분석 실패: {type(e).__name__}",
|
| 691 |
+
"url": url,
|
| 692 |
+
}
|
| 693 |
+
}
|
| 694 |
+
await producer.send_and_wait(
|
| 695 |
+
KAFKA_DONE_TOPIC,
|
| 696 |
+
key=analysis_id.encode("utf-8"),
|
| 697 |
+
value=json.dumps(err_payload, ensure_ascii=False).encode("utf-8")
|
| 698 |
+
)
|
| 699 |
+
logger.info(f"[KAFKA] produced error-done analysisId={analysis_id}")
|
| 700 |
|
| 701 |
finally:
|
| 702 |
logger.info("[KAFKA] stopped")
|