Revision: 3095
Author: jussi.ao.malinen
Date: Tue Apr 27 03:45:29 2010
Log: Corrections and cleanup for stopping test execution gracefully with ctrl-c, issue 108
http://code.google.com/p/robotframework/source/detail?r=3095

Modified:
 /trunk/src/robot/__init__.py
 /trunk/src/robot/running/handlers.py
 /trunk/src/robot/running/timeouts.py
 /trunk/src/robot/utils/signalhandler.py

=======================================
--- /trunk/src/robot/__init__.py        Mon Apr 26 06:26:12 2010
+++ /trunk/src/robot/__init__.py        Tue Apr 27 03:45:29 2010
@@ -28,7 +28,7 @@
         DATA_ERROR, STOPPED_BY_USER, FRAMEWORK_ERROR
 from variables import init_global_variables
 import utils
-from utils.signalhandler import ROBOT_SIGNAL_HANDLER
+from utils.signalhandler import STOP_SIGNAL_MONITOR

 __version__ = utils.version

@@ -91,7 +91,7 @@
     pybot /path/to/tests.html
     pybot --log mylog.html /path/to/tests.html /path/to/tests2.html
     """
-    ROBOT_SIGNAL_HANDLER.start()
+    STOP_SIGNAL_MONITOR.start()
     settings = RobotSettings(options)
     LOGGER.register_console_logger(settings['MonitorWidth'],
                                    settings['MonitorColors'])
=======================================
--- /trunk/src/robot/running/handlers.py        Mon Apr 26 06:26:12 2010
+++ /trunk/src/robot/running/handlers.py        Tue Apr 27 03:45:29 2010
@@ -20,7 +20,7 @@
 from arguments import PythonKeywordArguments, JavaKeywordArguments, \
     DynamicKeywordArguments, PythonInitArguments, JavaInitArguments, \
     RunKeywordArguments
-from robot.utils.signalhandler import ROBOT_SIGNAL_HANDLER
+from robot.utils.signalhandler import STOP_SIGNAL_MONITOR


 if utils.is_jython:
@@ -100,16 +100,14 @@
         return lambda: wrapped_handler(*positional, **named)

     def _wrap_with_signal_handling(self, runnable):
-        def _signal_wrapper(runnable):
-            def _wrapped_function(*wrapped_positional, **wrapped_named):
-                try:
-                    ROBOT_SIGNAL_HANDLER.start_running_keyword()
-                    return runnable(*wrapped_positional, **wrapped_named)
-                finally:
-                    ROBOT_SIGNAL_HANDLER.stop_running_keyword()
-            return _wrapped_function
-        return _signal_wrapper(runnable)
-
+        def _wrapped_function(*wrapped_positional, **wrapped_named):
+            try:
+                STOP_SIGNAL_MONITOR.start_running_keyword()
+                return runnable(*wrapped_positional, **wrapped_named)
+            finally:
+                STOP_SIGNAL_MONITOR.stop_running_keyword()
+        return _wrapped_function
+
     def _run_handler_with_output_captured(self, runner, output):
         utils.capture_output()
         try:
=======================================
--- /trunk/src/robot/running/timeouts.py        Thu Apr 15 05:45:39 2010
+++ /trunk/src/robot/running/timeouts.py        Tue Apr 27 03:45:29 2010
@@ -15,6 +15,7 @@
 import time

 from robot import utils
+from robot.utils.signalhandler import STOP_SIGNAL_MONITOR
 from robot.utils.robotthread import Thread, Runner, Event
 from robot.errors import TimeoutError, DataError, FrameworkError

@@ -87,6 +88,7 @@
         if runner.is_done():
             return runner.get_result()
         try:
+            STOP_SIGNAL_MONITOR.stop_running_keyword()
             thread.stop()
         except utils.RERAISED_EXCEPTIONS:
             raise
=======================================
--- /trunk/src/robot/utils/signalhandler.py     Mon Apr 26 06:26:12 2010
+++ /trunk/src/robot/utils/signalhandler.py     Tue Apr 27 03:45:29 2010
@@ -18,7 +18,7 @@
 from robot.errors import ExecutionFailed


-class _RobotSignalHandler(object):
+class _StopSignalMonitor(object):

     def __init__(self):
         self._signal_count = 0
@@ -29,7 +29,7 @@
         if self._signal_count > 1:
             sys.__stderr__.write("Execution forcefully stopped.")
             raise SystemExit()
- sys.__stderr__.write("Stopping execution. Second signal will force exit.") + sys.__stderr__.write("Stopping execution gracefully. Second signal will force exit.")
         if self._running_keyword:
             self._stop_execution_gracefully()

@@ -48,8 +48,5 @@
     def stop_running_keyword(self):
         self._running_keyword = False

-    def is_break_signaled(self):
-        return self.count > 0
-
-
-ROBOT_SIGNAL_HANDLER = _RobotSignalHandler()
+
+STOP_SIGNAL_MONITOR = _StopSignalMonitor()


--
Subscription settings: 
http://groups.google.com/group/robotframework-commit/subscribe?hl=en

Reply via email to