mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 23:30:10 +00:00
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:
parent
c0e055343e
commit
e9e5b5a329
@ -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)}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user