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
Browse files Browse the repository at this point in the history
  • Loading branch information
wintonzheng committed Oct 26, 2023
1 parent 5c29268 commit cd4b1d4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 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,11 @@ async def post(
logger.exception(f"Unexpected error error={e} request_payload={json}")
raise HTTPException(status_code=500, detail=str(e))
finally:
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 cd4b1d4

Please sign in to comment.