diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2019-01-23 15:50:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-23 15:50:25 +0000 |
commit | a0ae475219e48bdfcba37f893fed446a17e9a00d (patch) | |
tree | bffadaf4213c082dd8c23ed675e93507c088b270 /tests/server.py | |
parent | debian package: symlink to python-3.X (#4433) (diff) | |
parent | fix python2 test failure (diff) | |
download | synapse-a0ae475219e48bdfcba37f893fed446a17e9a00d.tar.xz |
Merge pull request #4428 from matrix-org/rav/matrix_federation_agent
Move SRV magic into an Agent-like thing
Diffstat (limited to 'tests/server.py')
-rw-r--r-- | tests/server.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/server.py b/tests/server.py index db43fa0db8..ed2a046ae6 100644 --- a/tests/server.py +++ b/tests/server.py @@ -1,4 +1,5 @@ import json +import logging from io import BytesIO from six import text_type @@ -22,6 +23,8 @@ from synapse.util import Clock from tests.utils import setup_test_homeserver as _sth +logger = logging.getLogger(__name__) + class TimedOutException(Exception): """ @@ -339,7 +342,7 @@ def get_clock(): return (clock, hs_clock) -@attr.s +@attr.s(cmp=False) class FakeTransport(object): """ A twisted.internet.interfaces.ITransport implementation which sends all its data @@ -414,6 +417,11 @@ class FakeTransport(object): self.buffer = self.buffer + byt def _write(): + if not self.buffer: + # nothing to do. Don't write empty buffers: it upsets the + # TLSMemoryBIOProtocol + return + if getattr(self.other, "transport") is not None: self.other.dataReceived(self.buffer) self.buffer = b"" @@ -421,7 +429,10 @@ class FakeTransport(object): self._reactor.callLater(0.0, _write) - _write() + # always actually do the write asynchronously. Some protocols (notably the + # TLSMemoryBIOProtocol) get very confused if a read comes back while they are + # still doing a write. Doing a callLater here breaks the cycle. + self._reactor.callLater(0.0, _write) def writeSequence(self, seq): for x in seq: |