How to combine python asyncio with threads?
It’s pretty simple to delegate a method to a thread or sub-process using BaseEventLoop.run_in_executor: import asyncio import time from concurrent.futures import ProcessPoolExecutor def cpu_bound_operation(x): time.sleep(x) # This is some operation that is CPU-bound @asyncio.coroutine def main(): # Run cpu_bound_operation in the ProcessPoolExecutor # This will make your coroutine block, but won’t block # the event … Read more