Skip to content
Permalink
Browse files

Merge pull request #4546 from matrix-org/rav/silence_critical_error_f…

…rom_federation

Fix noisy "twisted.internet.task.TaskStopped" errors in logs
  • Loading branch information...
richvdh committed Feb 1, 2019
2 parents f8db967 + f0ba34f commit ef43a03fc5aa002928796b22cdea185398a3e249
Showing with 16 additions and 2 deletions.
  1. +1 −0 changelog.d/4546.bugfix
  2. +15 −2 synapse/http/matrixfederationclient.py
@@ -0,0 +1 @@
Fix noisy "twisted.internet.task.TaskStopped" errors in logs
@@ -28,7 +28,7 @@
from prometheus_client import Counter
from signedjson.sign import sign_json

from twisted.internet import defer, protocol
from twisted.internet import defer, protocol, task
from twisted.internet.error import DNSLookupError
from twisted.internet.task import _EPSILON, Cooperator
from twisted.web._newclient import ResponseDone
@@ -286,7 +286,7 @@ def _send_request(
json,
)
data = encode_canonical_json(json)
producer = FileBodyProducer(
producer = QuieterFileBodyProducer(
BytesIO(data),
cooperator=self._cooperator,
)
@@ -839,3 +839,16 @@ def encode_query_args(args):
query_bytes = urllib.parse.urlencode(encoded_args, True)

return query_bytes.encode('utf8')


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

0 comments on commit ef43a03

Please sign in to comment.
You can’t perform that action at this time.