summary refs log tree commit diff
path: root/synapse/http/__init__.py
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2019-02-20 11:35:52 +0000
committerGitHub <noreply@github.com>2019-02-20 11:35:52 +0000
commitc88bc5390341162951fa4afc6b4a0644a30293dc (patch)
tree95ac52940edc6aa6df57aee735392521aaf7acb3 /synapse/http/__init__.py
parentClean up gitignores (#4688) (diff)
downloadsynapse-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__.py15
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