diff options
author | Amber Brown <hawkowl@atleastfornow.net> | 2019-05-13 15:01:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-13 15:01:14 -0500 |
commit | df2ebd75d3abde2bc2262551d8b2fd40c4b4bddf (patch) | |
tree | 398ff6183b805dd419951052296e45036b22da50 /tests/server.py | |
parent | Add ability to blacklist ip ranges for federation traffic (#5043) (diff) | |
download | synapse-df2ebd75d3abde2bc2262551d8b2fd40c4b4bddf.tar.xz |
Migrate all tests to use the dict-based config format instead of hanging items off HomeserverConfig (#5171)
Diffstat (limited to 'tests/server.py')
-rw-r--r-- | tests/server.py | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/tests/server.py b/tests/server.py index fc41345488..c15a47f2a4 100644 --- a/tests/server.py +++ b/tests/server.py @@ -227,6 +227,8 @@ class ThreadedMemoryReactorClock(MemoryReactorClock): """ def __init__(self): + self.threadpool = ThreadPool(self) + self._udp = [] lookups = self.lookups = {} @@ -255,6 +257,37 @@ class ThreadedMemoryReactorClock(MemoryReactorClock): self.callLater(0, d.callback, True) return d + def getThreadPool(self): + return self.threadpool + + +class ThreadPool: + """ + Threadless thread pool. + """ + + def __init__(self, reactor): + self._reactor = reactor + + def start(self): + pass + + def stop(self): + pass + + def callInThreadWithCallback(self, onResult, function, *args, **kwargs): + def _(res): + if isinstance(res, Failure): + onResult(False, res) + else: + onResult(True, res) + + d = Deferred() + d.addCallback(lambda x: function(*args, **kwargs)) + d.addBoth(_) + self._reactor.callLater(0, d.callback, True) + return d + def setup_test_homeserver(cleanup_func, *args, **kwargs): """ @@ -290,36 +323,10 @@ def setup_test_homeserver(cleanup_func, *args, **kwargs): **kwargs ) - class ThreadPool: - """ - Threadless thread pool. - """ - - def start(self): - pass - - def stop(self): - pass - - def callInThreadWithCallback(self, onResult, function, *args, **kwargs): - def _(res): - if isinstance(res, Failure): - onResult(False, res) - else: - onResult(True, res) - - d = Deferred() - d.addCallback(lambda x: function(*args, **kwargs)) - d.addBoth(_) - clock._reactor.callLater(0, d.callback, True) - return d - - clock.threadpool = ThreadPool() - if pool: pool.runWithConnection = runWithConnection pool.runInteraction = runInteraction - pool.threadpool = ThreadPool() + pool.threadpool = ThreadPool(clock._reactor) pool.running = True return d |