Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
always log events even if there's exception raised (#90)
Browse files Browse the repository at this point in the history
* always log events even if there's exception raised

* version bump

* add comment
  • Loading branch information
wintonzheng authored Oct 26, 2023
1 parent 5c29268 commit d4477a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "wyvern-ai"
version = "0.0.28"
version = "0.0.29"
description = ""
authors = ["Wyvern AI <[email protected]>"]
readme = "README.md"
Expand Down
13 changes: 6 additions & 7 deletions wyvern/web_frameworks/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,6 @@ async def post(
wyvern_req.execute_shadow_requests,
)

background_tasks.add_task(
wyvern_kinesis_firehose.put_record_batch_callable,
KinesisFirehoseStream.EVENT_STREAM,
# TODO (suchintan): "invariant" list error
event_logger.get_logged_events_generator(), # type: ignore
)

# profiler.stop()
# profiler.print(show_all=True)
except ValidationError as e:
Expand All @@ -188,6 +181,12 @@ async def post(
logger.exception(f"Unexpected error error={e} request_payload={json}")
raise HTTPException(status_code=500, detail=str(e))
finally:
# log events no matter exception or not
background_tasks.add_task(
wyvern_kinesis_firehose.put_record_batch_callable,
KinesisFirehoseStream.EVENT_STREAM,
event_logger.get_logged_events_generator(), # type: ignore
)
request_context.reset()
if not output:
raise HTTPException(status_code=500, detail="something is wrong")
Expand Down

0 comments on commit d4477a3

Please sign in to comment.