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 1858c3d commit d552a81
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 @@ -159,13 +159,6 @@ async def post(
await root_component.warm_up(data)
output = await root_component.execute(data)

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 @@ -184,6 +177,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 d552a81

Please sign in to comment.