import asyncio import concurrent.futures def run_other_thread(): pass @asyncio.coroutine def main_coro(loop): executor = concurrent.futures.ThreadPoolExecutor(20000) for i in range(40000): loop.run_in_executor(executor, run_other_thread) while True: print("5") yield from asyncio.sleep(5) def main(): loop = asyncio.ProactorEventLoop() asyncio.set_event_loop(loop) loop.create_task(main_coro(loop)) loop.run_forever() loop.close() if __name__ == "__main__": main()