Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
158:1187739e5a19 | 159:232989a6df36 |
---|---|
299 return pool, queue, abort | 299 return pool, queue, abort |
300 | 300 |
301 def _waitOnWorkerPool(self, pool, abort): | 301 def _waitOnWorkerPool(self, pool, abort): |
302 for w in pool: | 302 for w in pool: |
303 w.start() | 303 w.start() |
304 for w in pool: | 304 |
305 w.join() | 305 try: |
306 for w in pool: | |
307 w.join() | |
308 except KeyboardInterrupt: | |
309 logger.warning("Bake aborted by user... " | |
310 "waiting for workers to stop.") | |
311 abort.set() | |
312 for w in pool: | |
313 w.join() | |
314 raise | |
315 | |
306 if abort.is_set(): | 316 if abort.is_set(): |
307 excs = [w.abort_exception for w in pool | 317 excs = [w.abort_exception for w in pool |
308 if w.abort_exception is not None] | 318 if w.abort_exception is not None] |
309 logger.error("Baking was aborted due to %s error(s):" % len(excs)) | 319 logger.error("Baking was aborted due to %s error(s):" % len(excs)) |
310 if self.app.debug: | 320 if self.app.debug: |