def METHOD_NAME(self):
    executor = ThreadPoolExecutor()
    state = [None, None]  # type: List[Optional[QThread]]
    class StateSetter(QObject):
        didsetstate = Signal()
        def set_state(self, value: QThread) -> None:
            state[0] = value
            state[1] = QThread.currentThread()
            self.didsetstate.emit()
    def func(callback):  # type: (Callable[[QThread], None]) -> None
        callback(QThread.currentThread())
    obj = StateSetter()
    spy = QSignalSpy(obj.didsetstate)
    f = executor.submit(
        func, qinvoke(obj.set_state, context=obj)
    )
    self.assertTrue(spy.wait())
    self.assertIs(state[1], QThread.currentThread(),
                  "set_state was called from the wrong thread")
    self.assertIsNot(state[0], QThread.currentThread(),
                     "set_state was invoked in the main thread")
    # test that disconnect works 'atomically' w.r.t. event loop
    spy = QSignalSpy(obj.didsetstate)
    callback = qinvoke(obj.set_state, context=obj)
    f = executor.submit(func, callback)
    f.result()
    time.sleep(0.01)  # wait for finish
    callback.disconnect()  # type: ignore
    self.assertFalse(spy.wait(100), "")
    self.assertSequenceEqual(spy, [])
    executor.shutdown(wait=True)