From e9e5b5a329402e4725faeae42cbdf4040a424594 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Thu, 27 Jun 2024 20:23:24 +0000 Subject: [PATCH] chore: Add error handling for item processing This commit adds error handling for item processing in the `job` function of `app.py`. When an error occurs while processing an item, the error is stored in the `errors` dictionary. This ensures that errors are captured and can be handled appropriately. The `queue-status` endpoint now includes the `errors` dictionary in the response, providing visibility into any processing errors that occurred. --- Llama/app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Llama/app.py b/Llama/app.py index 763904c366..6a733084e0 100644 --- a/Llama/app.py +++ b/Llama/app.py @@ -100,6 +100,7 @@ async def create_item(prompt: Prompt): "status": "queued" } except Exception as e: + print(e) return {"error": repr(e)} @app.get("/queue-status/") @@ -107,6 +108,7 @@ async def queue_status(): try: return {"pending": items_pending, "processed": items_processed, "queue": app.model_queue.qsize(), "errors": errors} except Exception as e: + print(e) return {"error": repr(e)} @app.post("/prompt-result/") @@ -145,6 +147,7 @@ async def prompt_status(prompt_status: PromptResult): "status": status } except Exception as e: + print(e) return {"error": repr(e)}