summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-08-21 22:35:14 +0100
committerDavid Robertson <davidr@element.io>2022-08-21 22:35:14 +0100
commitc9e80bc77270b47a05c330a97a738b9904b2bb93 (patch)
treeca8c2b51d7e46443875d3703a041170264b2647e
parentAnnotate ThreadedMemoryReactorClock (diff)
downloadsynapse-c9e80bc77270b47a05c330a97a738b9904b2bb93.tar.xz
Annotate ThreadPool
-rw-r--r--tests/server.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/server.py b/tests/server.py
index 0a90c850f4..2d05077268 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -514,26 +514,32 @@ class ThreadedMemoryReactorClock(MemoryReactorClock):
 
 class ThreadPool:
     """
-    Threadless thread pool.
+    Threadless thread pool. A stand-in for twisted.python.threadpool.ThreadPool.
     """
 
-    def __init__(self, reactor):
+    def __init__(self, reactor: IReactorTime):
         self._reactor = reactor
 
-    def start(self):
+    def start(self) -> None:
         pass
 
-    def stop(self):
+    def stop(self) -> None:
         pass
 
-    def callInThreadWithCallback(self, onResult, function, *args, **kwargs):
-        def _(res):
+    def callInThreadWithCallback(
+        self,
+        onResult: Callable[[bool, object], Any],
+        function: Callable[P, Any],
+        *args: P.args,
+        **kwargs: P.kwargs,
+    ) -> "Deferred[bool]":
+        def _(res: object) -> None:
             if isinstance(res, Failure):
                 onResult(False, res)
             else:
                 onResult(True, res)
 
-        d = Deferred()
+        d: "Deferred[bool]" = Deferred()
         d.addCallback(lambda x: function(*args, **kwargs))
         d.addBoth(_)
         self._reactor.callLater(0, d.callback, True)