From a3348602c1d1f7c53bb3304125e153eae73388e5 Mon Sep 17 00:00:00 2001 From: io Date: Mon, 26 Jul 2021 06:17:01 +0000 Subject: [PATCH] fetch_posts: add KeyboardInterrupt handling --- fetch_posts.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fetch_posts.py b/fetch_posts.py index 95a0a4e..ba41d71 100755 --- a/fetch_posts.py +++ b/fetch_posts.py @@ -206,7 +206,11 @@ async def amain(): async with PostFetcher(config=config) as fetcher: await fetcher.fetch_all() def main(): - anyio.run(amain) + try: + anyio.run(amain) + except KeyboardInterrupt: + # suppress the lengthy traceback + sys.exit(1) if __name__ == '__main__': main()