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

Commit

Permalink
Always call .finish()
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Quah committed May 27, 2022
1 parent 2fdcec5 commit b401839
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions synapse/http/matrixfederationclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ async def _handle_response(
if max_response_size is None:
max_response_size = MAX_RESPONSE_SIZE

finished = False
try:
check_content_type_is(response.headers, parser.CONTENT_TYPE)

Expand All @@ -233,6 +234,7 @@ async def _handle_response(

length = await make_deferred_yieldable(d)

finished = True
value = parser.finish()
except BodyExceededMaxSize as e:
# The response was too big.
Expand Down Expand Up @@ -283,6 +285,15 @@ async def _handle_response(
e,
)
raise
finally:
if not finished:
# There was an exception and we didn't `finish()` the parse.
# Let the parser know that it can free up any resources.
try:
parser.finish()
except Exception:
# Ignore any additional exceptions.
pass

time_taken_secs = reactor.seconds() - start_ms / 1000

Expand Down

0 comments on commit b401839

Please sign in to comment.