Skip to content

Commit

Permalink
rest/media: Don't call finish in case of error
Browse files Browse the repository at this point in the history
When an exception occurs during the sending of data, the request doesn't
needs a finishing, otherwise twisted complains `Producer was not
unregistered for b'/_matrix/media/v1/thumbnail/…'`.

Fixes matrix-org#4933
  • Loading branch information
jo-so committed Mar 26, 2019
1 parent 5fee9d8 commit 9cb1642
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions synapse/rest/media/v1/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,14 @@ def respond_with_responder(request, responder, media_type, file_size, upload_nam
try:
with responder:
yield responder.write_to_consumer(request)

finish_request(request)
except Exception as e:
# The majority of the time this will be due to the client having gone
# away. Unfortunately, Twisted simply throws a generic exception at us
# in that case.
logger.warning("Failed to write to consumer: %s %s", type(e), e)

finish_request(request)
if str(e) != "Consumer asked us to stop producing":
logger.warning("Failed to write to consumer: %s %s", type(e), e)


class Responder(object):
Expand Down

0 comments on commit 9cb1642

Please sign in to comment.