From 91440ec621eb22412d2062f93ec1807b156f7d9b Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 9 Sep 2010 22:41:28 -0400 Subject: [PATCH] subprocesses catch keyboardinterrupt and raise a proper exception. This causes the parent process to re-raise the exception when it eventually tries to get() the result from the child, instead of hanging forever on a ctrl-C. It doesn't happen immediately, which is not ideal, but at least things will eventually exit on ctrl-C now. --- chunk.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chunk.py b/chunk.py index 3e9db04..ffdbbb9 100644 --- a/chunk.py +++ b/chunk.py @@ -52,6 +52,14 @@ def render_and_save(chunkfile, cave=False): import traceback traceback.print_exc() raise + except KeyboardInterrupt: + print + print "You pressed Ctrl-C. Unfortunately it got caught by a subprocess" + print "The program will terminate... eventually, but the main process" + print "may take a while to realize something went wrong." + print "To exit immediately, you'll need to kill this process some other" + print "way" + raise Exception() class ChunkRenderer(object): def __init__(self, chunkfile):