summaryrefslogtreecommitdiffstats
path: root/dimension/client.py.in
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2012-12-17 16:28:23 -0500
committerTavian Barnes <tavianator@tavianator.com>2012-12-17 16:36:29 -0500
commitc1c2d76ba9ec33fd94a06ba8c698d21bf4e1b774 (patch)
treec71d7e2c2a57a499d09f2dd8baef6595291e4953 /dimension/client.py.in
parent9defe68bb518bb7e4c7d6b9954a6f604191b7abd (diff)
downloaddimension-c1c2d76ba9ec33fd94a06ba8c698d21bf4e1b774.tar.xz
client: Respond to ^C right away if possible.
Diffstat (limited to 'dimension/client.py.in')
-rw-r--r--dimension/client.py.in17
1 files changed, 14 insertions, 3 deletions
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 <tavianator@tavianator.com> #
+# Copyright (C) 2011-2012 Tavian Barnes <tavianator@tavianator.com> #
# #
# 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