def test_callFromThread(self):
        """
        Test callFromThread functionality: from the main thread, and from
        another thread.
        """
        def cb(ign):
            firedByReactorThread = defer.Deferred()
            firedByOtherThread = defer.Deferred()

            def threadedFunc():
                reactor.callFromThread(firedByOtherThread.callback, None)

            reactor.callInThread(threadedFunc)
            reactor.callFromThread(firedByReactorThread.callback, None)

            return defer.DeferredList(
                [firedByReactorThread, firedByOtherThread],
                fireOnOneErrback=True)
        return self._waitForThread().addCallback(cb)

        Test callFromThread functionality: from the main thread, and from
        another thread.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_threads.py