diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2019-02-20 11:35:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-20 11:35:52 +0000 |
commit | c88bc5390341162951fa4afc6b4a0644a30293dc (patch) | |
tree | 95ac52940edc6aa6df57aee735392521aaf7acb3 /synapse/http/__init__.py | |
parent | Clean up gitignores (#4688) (diff) | |
download | synapse-c88bc5390341162951fa4afc6b4a0644a30293dc.tar.xz |
Fix TaskStopped exceptions when outbound requests time out (#4690)
Diffstat (limited to 'synapse/http/__init__.py')
-rw-r--r-- | synapse/http/__init__.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/http/__init__.py b/synapse/http/__init__.py index a3f9e4f67c..d36bcd6336 100644 --- a/synapse/http/__init__.py +++ b/synapse/http/__init__.py @@ -15,8 +15,10 @@ # limitations under the License. import re +from twisted.internet import task from twisted.internet.defer import CancelledError from twisted.python import failure +from twisted.web.client import FileBodyProducer from synapse.api.errors import SynapseError @@ -47,3 +49,16 @@ def redact_uri(uri): r'\1<redacted>\3', uri ) + + +class QuieterFileBodyProducer(FileBodyProducer): + """Wrapper for FileBodyProducer that avoids CRITICAL errors when the connection drops. + + Workaround for https://github.com/matrix-org/synapse/issues/4003 / + https://twistedmatrix.com/trac/ticket/6528 + """ + def stopProducing(self): + try: + FileBodyProducer.stopProducing(self) + except task.TaskStopped: + pass |