From c1c2d76ba9ec33fd94a06ba8c698d21bf4e1b774 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 17 Dec 2012 16:28:23 -0500 Subject: client: Respond to ^C right away if possible. --- dimension/client.py.in | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'dimension/client.py.in') diff --git a/dimension/client.py.in b/dimension/client.py.in index 9f68198..b1a3c60 100644 --- a/dimension/client.py.in +++ b/dimension/client.py.in @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ######################################################################### -# Copyright (C) 2011 Tavian Barnes # +# Copyright (C) 2011-2012 Tavian Barnes # # # # This file is part of Dimension. # # # @@ -172,7 +172,7 @@ def main(): else: print("Couldn't display preview window", file = sys.stderr) if bar is not None: - bar.join() + join_progress_bar(bar) # Write the output file export_timer = Timer() @@ -249,4 +249,15 @@ def progress_bar(str, future): def progress_bar_async(str, future): thread = threading.Thread(target = progress_bar, args = (str, future)) thread.start() - return thread + return (thread, future) + +def join_progress_bar(bar): + """Handle joining a progress bar thread in a way responsive to ^C.""" + thread = bar[0] + future = bar[1] + try: + thread.join() + except: + future.cancel() + thread.join() + raise -- cgit v1.2.3