Mercurial > piecrust2
diff piecrust/baking/baker.py @ 159:232989a6df36
Add support for KeyboardInterrupt in bake process.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 31 Dec 2014 19:50:40 -0800 |
parents | 1187739e5a19 |
children | aaf08277b96d |
line wrap: on
line diff
--- a/piecrust/baking/baker.py Wed Dec 31 16:56:55 2014 -0800 +++ b/piecrust/baking/baker.py Wed Dec 31 19:50:40 2014 -0800 @@ -301,8 +301,18 @@ def _waitOnWorkerPool(self, pool, abort): for w in pool: w.start() - for w in pool: - w.join() + + try: + for w in pool: + w.join() + except KeyboardInterrupt: + logger.warning("Bake aborted by user... " + "waiting for workers to stop.") + abort.set() + for w in pool: + w.join() + raise + if abort.is_set(): excs = [w.abort_exception for w in pool if w.abort_exception is not None]