for signame in ('SIGINT', 'SIGTERM'):
    loop.add_signal_handler(getattr(signal, signame), lambda : asyncio.
        ensure_future(ask_exit(signame)))
asyncio - How can coroutines be used in signal handlers?