def setup_test_homeserver(cleanup_func, *args, **kwargs):
    '\n    Set up a synchronous test server, driven by the reactor used by\n    the homeserver.\n    '
    d = _sth(cleanup_func, *args, **kwargs).result
    if isinstance(d, Failure):
        d.raiseException()
    clock = d.get_clock()
    pool = d.get_db_pool()

    def runWithConnection(func, *args, **kwargs):
        return threads.deferToThreadPool(pool._reactor, pool.threadpool, pool._runWithConnection, func, *args, **kwargs)

    def runInteraction(interaction, *args, **kwargs):
        return threads.deferToThreadPool(pool._reactor, pool.threadpool, pool._runInteraction, interaction, *args, **kwargs)
    pool.runWithConnection = runWithConnection
    pool.runInteraction = runInteraction

    class ThreadPool():
        '\n        Threadless thread pool.\n        '

        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()
    pool.threadpool = ThreadPool()
    pool.running = True
    return d
Set up a synchronous test server, driven by the reactor used by
the homeserver.
def setup_test_homeserver(cleanup_func, *args, **kwargs):
    '\n    Set up a synchronous test server, driven by the reactor used by\n    the homeserver.\n    '
    d = _sth(cleanup_func, *args, **kwargs).result
    if isinstance(d, Failure):
        d.raiseException()
    clock = d.get_clock()
    pool = d.get_db_pool()

    def runWithConnection(func, *args, **kwargs):
        return threads.deferToThreadPool(pool._reactor, pool.threadpool, pool._runWithConnection, func, *args, **kwargs)

    def runInteraction(interaction, *args, **kwargs):
        return threads.deferToThreadPool(pool._reactor, pool.threadpool, pool._runInteraction, interaction, *args, **kwargs)
    pool.runWithConnection = runWithConnection
    pool.runInteraction = runInteraction

    class ThreadPool():
        '\n        Threadless thread pool.\n        '

        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()
    pool.threadpool = ThreadPool()
    pool.running = True
    return d