changeset 10952:6c2c766afefe stable

dispatch: ignore if signals can not be set This happens if the code is executed in a thread. This patch allows tortoisehg to start the inotify server again.
author Simon Heimberg <simohe@besonet.ch>
date Wed, 07 Apr 2010 02:41:22 +0200
parents 5dc09507b90e
children f1250e2e8fd1
files mercurial/dispatch.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Thu Apr 01 22:04:30 2010 +0100
+++ b/mercurial/dispatch.py	Wed Apr 07 02:41:22 2010 +0200
@@ -33,10 +33,13 @@
     def catchterm(*args):
         raise error.SignalInterrupt
 
-    for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
-        num = getattr(signal, name, None)
-        if num:
-            signal.signal(num, catchterm)
+    try:
+        for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
+            num = getattr(signal, name, None)
+            if num:
+                signal.signal(num, catchterm)
+    except ValueError:
+        pass # happens if called in a thread
 
     try:
         try: