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.
This commit is contained in:
Simon Larsen 2024-06-27 20:23:24 +00:00
parent c0e055343e
commit e9e5b5a329

View File

@ -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)}