[meld] Ignore SIGINT on child processes to stop child tracebacks on Ctrl-C



commit 791c3fca2eff06db1e87464cc80700d3637ced2e
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Thu Oct 18 05:51:14 2012 +1000

    Ignore SIGINT on child processes to stop child tracebacks on Ctrl-C
    
    See http://bugs.python.org/issue8296, not fixed for
    multiprocessing.Pool.

 meld/filediff.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 17ae4dd..ada1409 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -21,6 +21,7 @@ import functools
 import multiprocessing
 import os
 from gettext import gettext as _
+import signal
 import sys
 import time
 
@@ -46,11 +47,15 @@ from meldapp import app
 from util.sourceviewer import srcviewer
 
 
+def init_worker():
+    signal.signal(signal.SIGINT, signal.SIG_IGN)
+
+
 def matcher_worker(text1, textn):
     matcher = matchers.InlineMyersSequenceMatcher(None, text1, textn)
     return matcher.get_opcodes()
 
-process_pool = multiprocessing.Pool()
+process_pool = multiprocessing.Pool(None, init_worker)
 
 
 class CachedSequenceMatcher(object):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]