mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 22:14:55 -04:00
Migrate all tests to use the dict-based config format instead of hanging items off HomeserverConfig (#5171)
This commit is contained in:
parent
5a4b328f52
commit
df2ebd75d3
23 changed files with 238 additions and 201 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue