worker: handle interrupt on windows
authorWojciech Lis <wlis@fb.com>
Mon, 18 Dec 2017 15:18:37 -0800
changeset 35457 44fd4cfc6c0a
parent 35456 488634db5928
child 35458 786289423e97
worker: handle interrupt on windows After applying suggestions from https://phab.mercurial-scm.org/D1564 to catch all exceptions in the same way I actually broke the handling of KeyboardInterrupt on windows. The reason is that KeyboardInterrupt doesn't dervie from Exception, but BaseException: https://docs.python.org/2/library/exceptions.html starting from python 2.5 Test Plan: Run hg on windows and ctrl-c during a large update. No random exceptions from threads surface in the shell. Previously we'd nearly always get stack traces from some of threads Run tests ./run-tests.py [...] Failed test-convert-svn-encoding.t: output changed # Ran 622 tests, 41 skipped, 1 failed. python hash seed: 2962682116 The test failing seems to have nothing to do with the change and fails on base revision as well Differential Revision: https://phab.mercurial-scm.org/D1718
mercurial/worker.py
--- a/mercurial/worker.py	Mon Dec 18 14:37:00 2017 -0800
+++ b/mercurial/worker.py	Mon Dec 18 15:18:37 2017 -0800
@@ -282,7 +282,7 @@
                 if t.exception is not None:
                     raise t.exception
                 threads.remove(t)
-    except Exception: # re-raises
+    except (Exception, KeyboardInterrupt): # re-raises
         trykillworkers()
         raise
     while not resultqueue.empty():