Revision: 3114
Author: jussi.ao.malinen
Date: Mon May  3 01:28:52 2010
Log: Changed signal handler to raise exception only once when ctrl-c is pressed.
http://code.google.com/p/robotframework/source/detail?r=3114

Modified:
 /trunk/src/robot/utils/signalhandler.py

=======================================
--- /trunk/src/robot/utils/signalhandler.py     Tue Apr 27 03:45:29 2010
+++ /trunk/src/robot/utils/signalhandler.py     Mon May  3 01:28:52 2010
@@ -23,18 +23,23 @@
     def __init__(self):
         self._signal_count = 0
         self._running_keyword = False
+        self._error_reported = False

     def __call__(self,signum, frame):
         self._signal_count += 1
         if self._signal_count > 1:
-            sys.__stderr__.write("Execution forcefully stopped.")
+            sys.__stderr__.write('Execution forcefully stopped.')
             raise SystemExit()
- sys.__stderr__.write("Stopping execution gracefully. Second signal will force exit.")
-        if self._running_keyword:
+        sys.__stderr__.write('Second signal will force exit.')
+        if self._running_keyword and not sys.platform.startswith('java'):
             self._stop_execution_gracefully()

     def _stop_execution_gracefully(self):
-        raise ExecutionFailed("Execution terminated by signal", exit=True)
+        # if in teardown, do nothing
+        # TODO: change method for teardown?
+        if not self._error_reported:
+            self._error_reported = True
+ raise ExecutionFailed('Execution terminated by signal', exit=True)

     def start(self):
         signal.signal(signal.SIGINT, self)

Reply via email to