summary refs log tree commit diff
path: root/tests/server.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2021-08-27 16:35:02 +0100
committerRichard van der Hoff <richard@matrix.org>2021-08-27 16:35:02 +0100
commite3abc0a5cc0669b76e5bdf2e1539645d790a7a3d (patch)
tree139c57d61b37fae528dc5d83cfa407a2f9a044d9 /tests/server.py
parent Removed page summaries from the top of installation and contributing doc pag... (diff)
parentFix incompatibility with Twisted < 21. (#10713) (diff)
downloadsynapse-e3abc0a5cc0669b76e5bdf2e1539645d790a7a3d.tar.xz
Merge remote-tracking branch 'origin/release-v1.41' into develop
Diffstat (limited to 'tests/server.py')
-rw-r--r--tests/server.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/server.py b/tests/server.py
index 6fddd3b305..b861c7b866 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -10,9 +10,10 @@ from zope.interface import implementer
 
 from twisted.internet import address, threads, udp
 from twisted.internet._resolver import SimpleResolverComplexifier
-from twisted.internet.defer import Deferred, fail, succeed
+from twisted.internet.defer import Deferred, fail, maybeDeferred, succeed
 from twisted.internet.error import DNSLookupError
 from twisted.internet.interfaces import (
+    IAddress,
     IHostnameResolver,
     IProtocol,
     IPullProducer,
@@ -511,6 +512,9 @@ class FakeTransport:
     will get called back for connectionLost() notifications etc.
     """
 
+    _peer_address: Optional[IAddress] = attr.ib(default=None)
+    """The value to be returend by getPeer"""
+
     disconnecting = False
     disconnected = False
     connected = True
@@ -519,7 +523,7 @@ class FakeTransport:
     autoflush = attr.ib(default=True)
 
     def getPeer(self):
-        return None
+        return self._peer_address
 
     def getHost(self):
         return None
@@ -572,7 +576,12 @@ class FakeTransport:
         self.producerStreaming = streaming
 
         def _produce():
-            d = self.producer.resumeProducing()
+            if not self.producer:
+                # we've been unregistered
+                return
+            # some implementations of IProducer (for example, FileSender)
+            # don't return a deferred.
+            d = maybeDeferred(self.producer.resumeProducing)
             d.addCallback(lambda x: self._reactor.callLater(0.1, _produce))
 
         if not streaming: