def _threaded_method(method_name, sync_name, reactor_name, threadpool_name):
    def _run_in_thread(self, *args, **kwargs):
        reactor = getattr(self, reactor_name)
        sync = getattr(self, sync_name)
        threadpool = getattr(self, threadpool_name)
        original = getattr(sync, method_name)
        return deferToThreadPool(
            reactor, threadpool, preserve_context(original), *args, **kwargs
        )
    return _run_in_thread
Create a method that calls another method in a threadpool.
dataset/ETHPy150Open ClusterHQ/flocker/flocker/common/_thread.py/_threaded_method