diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2019-01-30 10:55:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-30 10:55:25 +0000 |
commit | bc5f6e1797057e3acea692b926305982390424a3 (patch) | |
tree | fadca57abf7ce57ffc08d55af79fbc602f87a1f6 /tests/server.py | |
parent | Fix flake8 (#4519) (diff) | |
download | synapse-bc5f6e1797057e3acea692b926305982390424a3.tar.xz |
Add a caching layer to .well-known responses (#4516)
Diffstat (limited to 'tests/server.py')
-rw-r--r-- | tests/server.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/server.py b/tests/server.py index 3d7ae9875c..fc1e76d146 100644 --- a/tests/server.py +++ b/tests/server.py @@ -360,6 +360,7 @@ class FakeTransport(object): """ disconnecting = False + disconnected = False buffer = attr.ib(default=b'') producer = attr.ib(default=None) @@ -370,14 +371,16 @@ class FakeTransport(object): return None def loseConnection(self, reason=None): - logger.info("FakeTransport: loseConnection(%s)", reason) if not self.disconnecting: + logger.info("FakeTransport: loseConnection(%s)", reason) self.disconnecting = True if self._protocol: self._protocol.connectionLost(reason) + self.disconnected = True def abortConnection(self): - self.disconnecting = True + logger.info("FakeTransport: abortConnection()") + self.loseConnection() def pauseProducing(self): if not self.producer: @@ -416,9 +419,16 @@ class FakeTransport(object): # TLSMemoryBIOProtocol return + if self.disconnected: + return + logger.info("%s->%s: %s", self._protocol, self.other, self.buffer) + if getattr(self.other, "transport") is not None: - self.other.dataReceived(self.buffer) - self.buffer = b"" + try: + self.other.dataReceived(self.buffer) + self.buffer = b"" + except Exception as e: + logger.warning("Exception writing to protocol: %s", e) return self._reactor.callLater(0.0, _write) |