Created
July 25, 2019 02:26
-
-
Save amyreese/18c6f2730c3268c2777e474e11e95859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import signal | |
def handler(*args, **kwargs): | |
print(f"signal caught: {args} {kwargs}") | |
async def main(): | |
for i in reversed(range(15)): | |
print(i) | |
await asyncio.sleep(1) | |
loop = asyncio.get_event_loop() | |
loop.add_signal_handler(signal.SIGINT, handler) | |
loop.run_until_complete(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment