The easiest way to call the lock function from a coroutine is to use ThreadPoolExecutor, which returns futures compatible with coroutines:
thread_pool = ThreadPoolExecutor(4)
@gen.coroutine
def call_blocking():
yield thread_pool.submit(blocking_func, args)
blocking_func can use your economical function.
source
share