import asyncio import time @asyncio.coroutine def sleep_in_executor(loop): print("Going to sleep") yield from loop.run_in_executor(None, time.sleep, 1000) print("Wake up (you should not see this)") print("Start") loop = asyncio.get_event_loop() try: loop.run_until_complete(sleep_in_executor(loop)) finally: print("Closing loop") loop.close() print("End (you should not see this)")