2 new revisions:

Revision: 0bcda898a59f
Branch:   default
Author:   Robot Framework Developers (robotframew...@gmail.com)
Date:     Thu Oct 17 14:55:57 2013 UTC
Log: Process: Small enhancements to automatically killing non-terminated pr...
http://code.google.com/p/robotframework/source/detail?r=0bcda898a59f

Revision: 177f93ff3614
Branch:   default
Author:   Robot Framework Developers (robotframew...@gmail.com)
Date:     Thu Oct 17 14:57:20 2013 UTC
Log: Process: Small clean-up to Terminate Process returning result object....
http://code.google.com/p/robotframework/source/detail?r=177f93ff3614

==============================================================================
Revision: 0bcda898a59f
Branch:   default
Author:   Robot Framework Developers (robotframew...@gmail.com)
Date:     Thu Oct 17 14:55:57 2013 UTC
Log: Process: Small enhancements to automatically killing non-terminated process.

Update issue 1541
Status: Done
Cc: pekka.klarck
Looks very good. Small clean-up in this commit, though.
http://code.google.com/p/robotframework/source/detail?r=0bcda898a59f

Modified:
 /atest/robot/standard_libraries/process/terminate_and_pid.txt
 /atest/testdata/standard_libraries/process/terminate_and_pid.txt
 /src/robot/libraries/Process.py

=======================================
--- /atest/robot/standard_libraries/process/terminate_and_pid.txt Wed Oct 16 12:25:25 2013 UTC +++ /atest/robot/standard_libraries/process/terminate_and_pid.txt Thu Oct 17 14:55:57 2013 UTC
@@ -21,7 +21,7 @@
Check Log Message ${tc.kws[6].msgs[0]} Gracefully terminating process. Pass Execution If ${WINDOWS} Pass on Windows since there's no kill command. Check Log Message ${tc.kws[6].msgs[1]} Forcefully killing process.
-    Should Be True    ${tc.elapsedtime} > 5000
+    Should Be True    ${tc.elapsedtime} >= 2000

 Pid
     Check Test Case    ${TESTNAME}
=======================================
--- /atest/testdata/standard_libraries/process/terminate_and_pid.txt Wed Oct 16 12:37:59 2013 UTC +++ /atest/testdata/standard_libraries/process/terminate_and_pid.txt Thu Oct 17 14:55:57 2013 UTC
@@ -33,8 +33,8 @@

 Kill Process When Terminate Fails
     ${lib} =    Get Library Instance    Process
-    ${lib._terminate_timeout} =    Set Variable    ${5}
-    ${lib._kill_timeout} =    Set Variable    ${1}
+    ${lib.TERMINATE_TIMEOUT} =    Set Variable    ${2}
+    ${lib.KILL_TIMEOUT} =    Set Variable    ${1}
     ${process} =    Start Process    python    ${NONTERM}
     Process Should Be Running    ${process}
     Sleep   0.1
=======================================
--- /src/robot/libraries/Process.py     Wed Oct 16 14:53:42 2013 UTC
+++ /src/robot/libraries/Process.py     Thu Oct 17 14:55:57 2013 UTC
@@ -260,12 +260,12 @@
     """
     ROBOT_LIBRARY_SCOPE = 'GLOBAL'
     ROBOT_LIBRARY_VERSION = get_version()
+    TERMINATE_TIMEOUT = 30
+    KILL_TIMEOUT = 10

     def __init__(self):
         self._processes = ConnectionCache('No active process.')
         self._results = {}
-        self._terminate_timeout = 30
-        self._kill_timeout = 10

     def run_process(self, command, *arguments, **configuration):
         """Runs a process and waits for it to complete.
@@ -402,17 +402,19 @@

         If `handle` is not given, uses the current `active process`.

-        `kill` is a boolean value. If False, a graceful termination is
-        attempted and if the process remains running after 30 seconds it
-        will be forcefully killed. If True the process will immediately
-        be forcefully killed. If the process doesn't shut down in 10
-        seconds from killing it, an exception is raised.
+ Returns a `result object` containing information about the execution
+        similarly as `Wait For Process`.

-        See `Stopping process` for more details.
+ By default, tries to terminate the process gracefully, but forcefully
+        kills it if it does not stop in 30 seconds. Kills the process
+        immediately if `kill` argument is given any non-empty value.
+ On Unix-like machines termination is done using `TERM (15)` signal and
+        killing using `KILL (9)`. On Windows Win32 API is used directly.

- Returns a `result object` containing information about the execution.
+        See `Stopping process` for more details.

- Termination timeout and result value are new in Robot Framework 2.8.2 + Termination timeout and returning the result object are new features
+        in Robot Framework 2.8.2.
         """
         process = self._processes[handle]
         result = self._results[process]
@@ -425,20 +427,20 @@
             result.rc = process.wait() or 0
             return result
         except OSError:
-            if not self._process_is_stopped(process, self._kill_timeout):
+            if not self._process_is_stopped(process, self.KILL_TIMEOUT):
                 raise
             logger.debug('Ignored OSError because process was stopped.')

     def _kill_process(self, process):
         logger.info('Forcefully killing process.')
         process.kill()
-        if not self._process_is_stopped(process, self._kill_timeout):
+        if not self._process_is_stopped(process, self.KILL_TIMEOUT):
             raise

     def _terminate_process(self, process):
         logger.info('Gracefully terminating process.')
         process.terminate()
-        if not self._process_is_stopped(process, self._terminate_timeout):
+        if not self._process_is_stopped(process, self.TERMINATE_TIMEOUT):
             self._kill_process(process)

     def terminate_all_processes(self, kill=False):

==============================================================================
Revision: 177f93ff3614
Branch:   default
Author:   Robot Framework Developers (robotframew...@gmail.com)
Date:     Thu Oct 17 14:57:20 2013 UTC
Log: Process: Small clean-up to Terminate Process returning result object.

Update issue 1543
Status: Done
Cc: pekka.klarck
Looks very good. Small clean-up included.
http://code.google.com/p/robotframework/source/detail?r=177f93ff3614

Modified:
 /atest/testdata/standard_libraries/process/terminate_and_pid.txt
 /src/robot/libraries/Process.py

=======================================
--- /atest/testdata/standard_libraries/process/terminate_and_pid.txt Thu Oct 17 14:55:57 2013 UTC +++ /atest/testdata/standard_libraries/process/terminate_and_pid.txt Thu Oct 17 14:57:20 2013 UTC
@@ -19,17 +19,19 @@
     ${handle}=    Some process
     Process Should Be Running
     ${result} =    Terminate Process    ${handle}    kill=${True}
-    Wait For Process    ${handle}
     Process Should Be Stopped    ${handle}
     Should Not Be Equal As Integers    ${result.rc}    0
+    Should Be Empty    ${result.stdout}
+    Should Be Empty    ${result.stderr}

 Terminating process
     ${handle}=    Some process
     Process Should Be Running
     ${result} =    Terminate Process    ${handle}
-    Wait For Process    ${handle}
     Process Should Be Stopped    ${handle}
     Should Not Be Equal As Integers     ${result.rc}    0
+    Should Be Empty    ${result.stdout}
+    Should Be Empty    ${result.stderr}

 Kill Process When Terminate Fails
     ${lib} =    Get Library Instance    Process
=======================================
--- /src/robot/libraries/Process.py     Thu Oct 17 14:55:57 2013 UTC
+++ /src/robot/libraries/Process.py     Thu Oct 17 14:57:20 2013 UTC
@@ -424,12 +424,12 @@
terminator = self._kill_process if kill else self._terminate_process
         try:
             terminator(process)
-            result.rc = process.wait() or 0
-            return result
         except OSError:
             if not self._process_is_stopped(process, self.KILL_TIMEOUT):
                 raise
             logger.debug('Ignored OSError because process was stopped.')
+        result.rc = process.wait() or 0
+        return result

     def _kill_process(self, process):
         logger.info('Forcefully killing process.')

--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to