Skip to content

Commit

Permalink
Dispatch http.lifecyle.response from exception handler (sanic-org#2299)
Browse files Browse the repository at this point in the history
  • Loading branch information
whos4n3 authored and ChihweiLHBird committed Jun 1, 2022
1 parent c4ed3d6 commit 5695c65
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sanic/app.py
Expand Up @@ -775,6 +775,14 @@ async def handle_exception(
if request.stream:
response = request.stream.response
if isinstance(response, BaseHTTPResponse):
await self.dispatch(
"http.lifecycle.response",
inline=True,
context={
"request": request,
"response": response,
},
)
await response.send(end_stream=True)
else:
raise ServerError(
Expand Down

0 comments on commit 5695c65

Please sign in to comment.