def deterministicReactorThreads():
    """
    Create a deterministic L{IReactorThreads}

    @return: a 2-tuple consisting of an L{IReactorThreads}-like object and a
        0-argument callable that will perform one unit of work invoked via that
        object's C{callFromThread} method.
    """
    worker, doer = createMemoryWorker()
    class CFT(object):
        def callFromThread(self, f, *a, **k):
            worker.do(lambda: f(*a, **k))
    return CFT(), doer

    Create a deterministic L{IReactorThreads}

    @return: a 2-tuple consisting of an L{IReactorThreads}-like object and a
        0-argument callable that will perform one unit of work invoked via that
        object's C{callFromThread} method.
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/test/test_resolver.py