Robot Framework library for running processes. More...
Public Member Functions | |
| def | __init__ (self) |
| def | get_process_id (self, handle=None) |
| Returns the process ID (pid) of the process as an integer. More... | |
| def | get_process_object (self, handle=None) |
Return the underlying subprocess.Popen object. More... | |
| def | get_process_result (self, handle=None, rc=False, stdout=False, stderr=False, stdout_path=False, stderr_path=False) |
Returns the specified result object or some of its attributes. More... | |
| def | is_process_running (self, handle=None) |
| Checks is the process running or not. More... | |
| def | join_command_line (self, *args) |
| Joins arguments into one command line string. More... | |
| def | process_should_be_running (self, handle=None, error_message='Process is not running.') |
| Verifies that the process is running. More... | |
| def | process_should_be_stopped (self, handle=None, error_message='Process is running.') |
| Verifies that the process is not running. More... | |
| def | run_process (self, command, *arguments, **configuration) |
| Runs a process and waits for it to complete. More... | |
| def | send_signal_to_process (self, signal, handle=None, group=False) |
Sends the given signal to the specified process. More... | |
| def | split_command_line (self, args, escaping=False) |
| Splits command line string into a list of arguments. More... | |
| def | start_process (self, command, *arguments, **configuration) |
| Starts a new process on background. More... | |
| def | switch_process (self, handle) |
Makes the specified process the current active process. More... | |
| def | terminate_all_processes (self, kill=False) |
| Terminates all still running processes started by this library. More... | |
| def | terminate_process (self, handle=None, kill=False) |
| Stops the process gracefully or forcefully. More... | |
| def | wait_for_process (self, handle=None, timeout=None, on_timeout='continue') |
| Waits for the process to complete or to reach the given timeout. More... | |
Static Public Attributes | |
| int | KILL_TIMEOUT = 10 |
| string | ROBOT_LIBRARY_SCOPE = 'GLOBAL' |
| ROBOT_LIBRARY_VERSION = get_version() | |
| int | TERMINATE_TIMEOUT = 30 |
Private Member Functions | |
| def | _convert_signal_name_to_number (self, name) |
| def | _get_result_attributes (self, result, *includes) |
| def | _get_signal_number (self, int_or_name) |
| def | _get_timeout (self, timeout) |
| def | _kill (self, process) |
| def | _log_start (self, command, config) |
| def | _manage_process_timeout (self, handle, on_timeout) |
| def | _process_is_stopped (self, process, timeout) |
| def | _terminate (self, process) |
| def | _wait (self, process) |
Private Attributes | |
| _processes | |
| _results | |
Robot Framework library for running processes.
This library utilizes Python's
[http://docs.python.org/library/subprocess.html|subprocess]
module and its
[http://docs.python.org/library/subprocess.html#popen-constructor|Popen]
class.
The library has following main usages:
- Running processes in system and waiting for their completion using
`Run Process` keyword.
- Starting processes on background using `Start Process`.
- Waiting started process to complete using `Wait For Process` or
stopping them with `Terminate Process` or `Terminate All Processes`.
== Table of contents ==
%TOC%
= Specifying command and arguments =
Both `Run Process` and `Start Process` accept the command to execute and
all arguments passed to the command as separate arguments. This makes usage
convenient and also allows these keywords to automatically escape possible
spaces and other special characters in commands and arguments. Notice that
if a command accepts options that themselves accept values, these options
and their values must be given as separate arguments.
When `running processes in shell`, it is also possible to give the whole
command to execute as a single string. The command can then contain
multiple commands to be run together. When using this approach, the caller
is responsible on escaping.
Examples:
| `Run Process` | ${tools}${/}prog.py | argument | second arg with spaces |
| `Run Process` | java | -jar | ${jars}${/}example.jar | --option | value |
| `Run Process` | prog.py "one arg" && tool.sh | shell=yes | cwd=${tools} |
Possible non-string arguments are converted to strings automatically.
= Process configuration =
`Run Process` and `Start Process` keywords can be configured using
optional ``**configuration`` keyword arguments. Configuration arguments
must be given after other arguments passed to these keywords and must
use syntax like ``name=value``. Available configuration arguments are
listed below and discussed further in sections afterwards.
| = Name = | = Explanation = |
| shell | Specifies whether to run the command in shell or not. |
| cwd | Specifies the working directory. |
| env | Specifies environment variables given to the process. |
| env:<name> | Overrides the named environment variable(s) only. |
| stdout | Path of a file where to write standard output. |
| stderr | Path of a file where to write standard error. |
| stdin | Configure process standard input. New in RF 4.1.2. |
| output_encoding | Encoding to use when reading command outputs. |
| alias | Alias given to the process. |
Note that because ``**configuration`` is passed using ``name=value`` syntax,
possible equal signs in other arguments passed to `Run Process` and
`Start Process` must be escaped with a backslash like ``name\\=value``.
See `Run Process` for an example.
== Running processes in shell ==
The ``shell`` argument specifies whether to run the process in a shell or
not. By default shell is not used, which means that shell specific commands,
like ``copy`` and ``dir`` on Windows, are not available. You can, however,
run shell scripts and batch files without using a shell.
Giving the ``shell`` argument any non-false value, such as ``shell=True``,
changes the program to be executed in a shell. It allows using the shell
capabilities, but can also make the process invocation operating system
dependent. Having a shell between the actually started process and this
library can also interfere communication with the process such as stopping
it and reading its outputs. Because of these problems, it is recommended
to use the shell only when absolutely necessary.
When using a shell it is possible to give the whole command to execute
as a single string. See `Specifying command and arguments` section for
examples and more details in general.
== Current working directory ==
By default, the child process will be executed in the same directory
as the parent process, the process running Robot Framework, is executed. This
can be changed by giving an alternative location using the ``cwd`` argument.
Forward slashes in the given path are automatically converted to
backslashes on Windows.
`Standard output and error streams`, when redirected to files,
are also relative to the current working directory possibly set using
the ``cwd`` argument.
Example:
| `Run Process` | prog.exe | cwd=${ROOT}/directory | stdout=stdout.txt |
== Environment variables ==
By default the child process will get a copy of the parent process's
environment variables. The ``env`` argument can be used to give the
child a custom environment as a Python dictionary. If there is a need
to specify only certain environment variable, it is possible to use the
``env:<name>=<value>`` format to set or override only that named variables.
It is also possible to use these two approaches together.
Examples:
| `Run Process` | program | env=${environ} |
| `Run Process` | program | env:http_proxy=10.144.1.10:8080 | env:PATH=%{PATH}${:}${PROGDIR} |
| `Run Process` | program | env=${environ} | env:EXTRA=value |
== Standard output and error streams ==
By default processes are run so that their standard output and standard
error streams are kept in the memory. This works fine normally,
but if there is a lot of output, the output buffers may get full and
the program can hang.
To avoid the above mentioned problems, it is possible to use ``stdout``
and ``stderr`` arguments to specify files on the file system where to
redirect the outputs. This can also be useful if other processes or
other keywords need to read or manipulate the outputs somehow.
Given ``stdout`` and ``stderr`` paths are relative to the `current working
directory`. Forward slashes in the given paths are automatically converted
to backslashes on Windows.
As a special feature, it is possible to redirect the standard error to
the standard output by using ``stderr=STDOUT``.
Regardless are outputs redirected to files or not, they are accessible
through the `result object` returned when the process ends. Commands are
expected to write outputs using the console encoding, but `output encoding`
can be configured using the ``output_encoding`` argument if needed.
If you are not interested in outputs at all, you can explicitly ignore them
by using a special value ``DEVNULL`` both with ``stdout`` and ``stderr``. For
example, ``stdout=DEVNULL`` is the same as redirecting output on console
with ``> /dev/null`` on UNIX-like operating systems or ``> NUL`` on Windows.
This way the process will not hang even if there would be a lot of output,
but naturally output is not available after execution either.
Support for the special value ``DEVNULL`` is new in Robot Framework 3.2.
Examples:
| ${result} = | `Run Process` | program | stdout=${TEMPDIR}/stdout.txt | stderr=${TEMPDIR}/stderr.txt |
| `Log Many` | stdout: ${result.stdout} | stderr: ${result.stderr} |
| ${result} = | `Run Process` | program | stderr=STDOUT |
| `Log` | all output: ${result.stdout} |
| ${result} = | `Run Process` | program | stdout=DEVNULL | stderr=DEVNULL |
Note that the created output files are not automatically removed after
the test run. The user is responsible to remove them if needed.
== Standard input stream ==
The ``stdin`` argument makes it possible to pass information to the standard
input stream of the started process. How its value is interpreted is
explained in the table below.
| = Value = | = Explanation = |
| String ``PIPE`` | Make stdin a pipe that can be written to. This is the default. |
| String ``NONE`` | Inherit stdin from the parent process. This value is case-insensitive. |
| Path to a file | Open the specified file and use it as the stdin. |
| Any other string | Create a temporary file with the text as its content and use it as the stdin. |
| Any non-string value | Used as-is. Could be a file descriptor, stdout of another process, etc. |
Values ``PIPE`` and ``NONE`` are internally mapped directly to
``subprocess.PIPE`` and ``None``, respectively, when calling
[https://docs.python.org/3/library/subprocess.html#subprocess.Popen|subprocess.Popen].
The default behavior may change from ``PIPE`` to ``NONE`` in future
releases. If you depend on the ``PIPE`` behavior, it is a good idea to use
it explicitly.
Examples:
| `Run Process` | command | stdin=NONE |
| `Run Process` | command | stdin=${CURDIR}/stdin.txt |
| `Run Process` | command | stdin=Stdin as text. |
The support to configure ``stdin`` is new in Robot Framework 4.1.2.
== Output encoding ==
Executed commands are, by default, expected to write outputs to the
`standard output and error streams` using the encoding used by the
system console. If the command uses some other encoding, that can be
configured using the ``output_encoding`` argument. This is especially
useful on Windows where the console uses a different encoding than rest
of the system, and many commands use the general system encoding instead
of the console encoding.
The value used with the ``output_encoding`` argument must be a valid
encoding and must match the encoding actually used by the command. As a
convenience, it is possible to use strings ``CONSOLE`` and ``SYSTEM``
to specify that the console or system encoding is used, respectively.
If produced outputs use different encoding then configured, values got
through the `result object` will be invalid.
Examples:
| `Start Process` | program | output_encoding=UTF-8 |
| `Run Process` | program | stdout=${path} | output_encoding=SYSTEM |
== Alias ==
A custom name given to the process that can be used when selecting the
`active process`.
Examples:
| `Start Process` | program | alias=example |
| `Run Process` | python | -c | print('hello') | alias=hello |
= Active process =
The library keeps record which of the started processes is currently active.
By default it is the latest process started with `Start Process`,
but `Switch Process` can be used to activate a different process. Using
`Run Process` does not affect the active process.
The keywords that operate on started processes will use the active process
by default, but it is possible to explicitly select a different process
using the ``handle`` argument. The handle can be an ``alias`` explicitly
given to `Start Process` or the process object returned by it.
= Result object =
`Run Process`, `Wait For Process` and `Terminate Process` keywords return a
result object that contains information about the process execution as its
attributes. The same result object, or some of its attributes, can also
be get using `Get Process Result` keyword. Attributes available in the
object are documented in the table below.
| = Attribute = | = Explanation = |
| rc | Return code of the process as an integer. |
| stdout | Contents of the standard output stream. |
| stderr | Contents of the standard error stream. |
| stdout_path | Path where stdout was redirected or ``None`` if not redirected. |
| stderr_path | Path where stderr was redirected or ``None`` if not redirected. |
Example:
| ${result} = | `Run Process` | program |
| `Should Be Equal As Integers` | ${result.rc} | 0 |
| `Should Match` | ${result.stdout} | Some t?xt* |
| `Should Be Empty` | ${result.stderr} | |
| ${stdout} = | `Get File` | ${result.stdout_path} |
| `Should Be Equal` | ${stdout} | ${result.stdout} |
| `File Should Be Empty` | ${result.stderr_path} | |
= Boolean arguments =
Some keywords accept arguments that are handled as Boolean values true or
false. If such an argument is given as a string, it is considered false if
it is an empty string or equal to ``FALSE``, ``NONE``, ``NO``, ``OFF`` or
``0``, case-insensitively. Other strings are considered true regardless
their value, and other argument types are tested using the same
[http://docs.python.org/library/stdtypes.html#truth|rules as in Python].
True examples:
| `Terminate Process` | kill=True | # Strings are generally true. |
| `Terminate Process` | kill=yes | # Same as the above. |
| `Terminate Process` | kill=${TRUE} | # Python ``True`` is true. |
| `Terminate Process` | kill=${42} | # Numbers other than 0 are true. |
False examples:
| `Terminate Process` | kill=False | # String ``false`` is false. |
| `Terminate Process` | kill=no | # Also string ``no`` is false. |
| `Terminate Process` | kill=${EMPTY} | # Empty string is false. |
| `Terminate Process` | kill=${FALSE} | # Python ``False`` is false. |
Considering ``OFF`` and ``0`` false is new in Robot Framework 3.1.
= Example =
| ***** Settings *****
| Library Process
| Suite Teardown `Terminate All Processes` kill=True
|
| ***** Test Cases *****
| Example
| `Start Process` program arg1 arg2 alias=First
| ${handle} = `Start Process` command.sh arg | command2.sh shell=True cwd=/path
| ${result} = `Run Process` ${CURDIR}/script.py
| `Should Not Contain` ${result.stdout} FAIL
| `Terminate Process` ${handle}
| ${result} = `Wait For Process` First
| `Should Be Equal As Integers` ${result.rc} 0
Definition at line 318 of file Process.py.
| def robot.libraries.Process.Process.__init__ | ( | self | ) |
Definition at line 324 of file Process.py.
|
private |
Definition at line 658 of file Process.py.
|
private |
Definition at line 740 of file Process.py.
|
private |
Definition at line 652 of file Process.py.
|
private |
Definition at line 509 of file Process.py.
|
private |
Definition at line 574 of file Process.py.
|
private |
Definition at line 413 of file Process.py.
|
private |
Definition at line 514 of file Process.py.
|
private |
Definition at line 761 of file Process.py.
|
private |
Definition at line 583 of file Process.py.
|
private |
Definition at line 523 of file Process.py.
| def robot.libraries.Process.Process.get_process_id | ( | self, | |
handle = None |
|||
| ) |
Returns the process ID (pid) of the process as an integer.
If ``handle`` is not given, uses the current `active process`.
Starting from Robot Framework 5.0, it is also possible to directly access
the ``pid`` attribute of the ``subprocess.Popen`` object returned by
`Start Process` like ``${process.pid}``.
Definition at line 673 of file Process.py.
| def robot.libraries.Process.Process.get_process_object | ( | self, | |
handle = None |
|||
| ) |
Return the underlying subprocess.Popen object.
If ``handle`` is not given, uses the current `active process`.
Starting from Robot Framework 5.0, `Start Process` returns the created
``subprocess.Popen`` object, not a generic handle, making this keyword
mostly redundant.
Definition at line 684 of file Process.py.
| def robot.libraries.Process.Process.get_process_result | ( | self, | |
handle = None, |
|||
rc = False, |
|||
stdout = False, |
|||
stderr = False, |
|||
stdout_path = False, |
|||
stderr_path = False |
|||
| ) |
Returns the specified result object or some of its attributes.
The given ``handle`` specifies the process whose results should be
returned. If no ``handle`` is given, results of the current `active
process` are returned. In either case, the process must have been
finishes before this keyword can be used. In practice this means
that processes started with `Start Process` must be finished either
with `Wait For Process` or `Terminate Process` before using this
keyword.
If no other arguments than the optional ``handle`` are given, a whole
`result object` is returned. If one or more of the other arguments
are given any true value, only the specified attributes of the
`result object` are returned. These attributes are always returned
in the same order as arguments are specified in the keyword signature.
See `Boolean arguments` section for more details about true and false
values.
Examples:
| Run Process | python | -c | print('Hello, world!') | alias=myproc |
| # Get result object | | |
| ${result} = | Get Process Result | myproc |
| Should Be Equal | ${result.rc} | ${0} |
| Should Be Equal | ${result.stdout} | Hello, world! |
| Should Be Empty | ${result.stderr} | |
| # Get one attribute | | |
| ${stdout} = | Get Process Result | myproc | stdout=true |
| Should Be Equal | ${stdout} | Hello, world! |
| # Multiple attributes | | |
| ${stdout} | ${stderr} = | Get Process Result | myproc | stdout=yes | stderr=yes |
| Should Be Equal | ${stdout} | Hello, world! |
| Should Be Empty | ${stderr} | |
Although getting results of a previously executed process can be handy
in general, the main use case for this keyword is returning results
over the remote library interface. The remote interface does not
support returning the whole result object, but individual attributes
can be returned without problems.
Definition at line 726 of file Process.py.
| def robot.libraries.Process.Process.is_process_running | ( | self, | |
handle = None |
|||
| ) |
Checks is the process running or not.
If ``handle`` is not given, uses the current `active process`.
Returns ``True`` if the process is still running and ``False`` otherwise.
Definition at line 425 of file Process.py.
| def robot.libraries.Process.Process.join_command_line | ( | self, | |
| * | args | ||
| ) |
Joins arguments into one command line string.
In resulting command line string arguments are delimited with a space,
arguments containing spaces are surrounded with quotes, and possible
quotes are escaped with a backslash.
If this keyword is given only one argument and that is a list like
object, then the values of that list are joined instead.
Example:
| ${cmd} = | Join Command Line | --option | value with spaces |
| Should Be Equal | ${cmd} | --option "value with spaces" |
Definition at line 796 of file Process.py.
| def robot.libraries.Process.Process.process_should_be_running | ( | self, | |
handle = None, |
|||
error_message = 'Process is not running.' |
|||
| ) |
Verifies that the process is running.
If ``handle`` is not given, uses the current `active process`.
Fails if the process has stopped.
Definition at line 434 of file Process.py.
| def robot.libraries.Process.Process.process_should_be_stopped | ( | self, | |
handle = None, |
|||
error_message = 'Process is running.' |
|||
| ) |
Verifies that the process is not running.
If ``handle`` is not given, uses the current `active process`.
Fails if the process is still running.
Definition at line 445 of file Process.py.
| def robot.libraries.Process.Process.run_process | ( | self, | |
| command, | |||
| * | arguments, | ||
| ** | configuration | ||
| ) |
Runs a process and waits for it to complete.
``command`` and ``*arguments`` specify the command to execute and
arguments passed to it. See `Specifying command and arguments` for
more details.
``**configuration`` contains additional configuration related to
starting processes and waiting for them to finish. See `Process
configuration` for more details about configuration related to starting
processes. Configuration related to waiting for processes consists of
``timeout`` and ``on_timeout`` arguments that have same semantics as
with `Wait For Process` keyword. By default there is no timeout, and
if timeout is defined the default action on timeout is ``terminate``.
Returns a `result object` containing information about the execution.
Note that possible equal signs in ``*arguments`` must be escaped
with a backslash (e.g. ``name\\=value``) to avoid them to be passed in
as ``**configuration``.
Examples:
| ${result} = | Run Process | python | -c | print('Hello, world!') |
| Should Be Equal | ${result.stdout} | Hello, world! |
| ${result} = | Run Process | ${command} | stderr=STDOUT | timeout=10s |
| ${result} = | Run Process | ${command} | timeout=1min | on_timeout=continue |
| ${result} = | Run Process | java -Dname\\=value Example | shell=True | cwd=${EXAMPLE} |
This keyword does not change the `active process`.
Definition at line 357 of file Process.py.
| def robot.libraries.Process.Process.send_signal_to_process | ( | self, | |
| signal, | |||
handle = None, |
|||
group = False |
|||
| ) |
Sends the given signal to the specified process.
If ``handle`` is not given, uses the current `active process`.
Signal can be specified either as an integer as a signal name. In the
latter case it is possible to give the name both with or without ``SIG``
prefix, but names are case-sensitive. For example, all the examples
below send signal ``INT (2)``:
| Send Signal To Process | 2 | | # Send to active process |
| Send Signal To Process | INT | | |
| Send Signal To Process | SIGINT | myproc | # Send to named process |
This keyword is only supported on Unix-like machines, not on Windows.
What signals are supported depends on the system. For a list of
existing signals on your system, see the Unix man pages related to
signal handling (typically ``man signal`` or ``man 7 signal``).
By default sends the signal only to the parent process, not to possible
child processes started by it. Notice that when `running processes in
shell`, the shell is the parent process and it depends on the system
does the shell propagate the signal to the actual started process.
To send the signal to the whole process group, ``group`` argument can
be set to any true value (see `Boolean arguments`).
Definition at line 638 of file Process.py.
| def robot.libraries.Process.Process.split_command_line | ( | self, | |
| args, | |||
escaping = False |
|||
| ) |
Splits command line string into a list of arguments.
String is split from spaces, but argument surrounded in quotes may
contain spaces in them. If ``escaping`` is given a true value, then
backslash is treated as an escape character. It can escape unquoted
spaces, quotes inside quotes, and so on, but it also requires using
double backslashes when using Windows paths.
Examples:
| @{cmd} = | Split Command Line | --option "value with spaces" |
| Should Be True | $cmd == ['--option', 'value with spaces'] |
Definition at line 780 of file Process.py.
| def robot.libraries.Process.Process.start_process | ( | self, | |
| command, | |||
| * | arguments, | ||
| ** | configuration | ||
| ) |
Starts a new process on background.
See `Specifying command and arguments` and `Process configuration`
for more information about the arguments, and `Run Process` keyword
for related examples.
Makes the started process new `active process`. Returns the created
[https://docs.python.org/3/library/subprocess.html#popen-constructor |
subprocess.Popen] object which can be be used later to active this
process. ``Popen`` attributes like ``pid`` can also be accessed directly.
Processes are started so that they create a new process group. This
allows terminating and sending signals to possible child processes.
Examples:
Start process and wait for it to end later using alias:
| `Start Process` | ${command} | alias=example |
| # Other keywords |
| ${result} = | `Wait For Process` | example |
Use returned ``Popen`` object:
| ${process} = | `Start Process` | ${command} |
| `Log` | PID: ${process.pid} |
| # Other keywords |
| ${result} = | `Terminate Process` | ${process} |
Use started process in a pipeline with another process:
| ${process} = | `Start Process` | python | -c | print('Hello, world!') |
| ${result} = | `Run Process` | python | -c | import sys; print(sys.stdin.read().upper().strip()) | stdin=${process.stdout} |
| `Wait For Process` | ${process} |
| `Should Be Equal` | ${result.stdout} | HELLO, WORLD! |
Returning a ``subprocess.Popen`` object is new in Robot Framework 5.0.
Earlier versions returned a generic handle and getting the process object
required using `Get Process Object` separately.
Definition at line 404 of file Process.py.
| def robot.libraries.Process.Process.switch_process | ( | self, | |
| handle | |||
| ) |
Makes the specified process the current active process.
The handle can be an identifier returned by `Start Process` or
the ``alias`` given to it explicitly.
Example:
| Start Process | prog1 | alias=process1 |
| Start Process | prog2 | alias=process2 |
| # currently active process is process2 |
| Switch Process | process1 |
| # now active process is process1 |
Definition at line 758 of file Process.py.
| def robot.libraries.Process.Process.terminate_all_processes | ( | self, | |
kill = False |
|||
| ) |
Terminates all still running processes started by this library.
This keyword can be used in suite teardown or elsewhere to make
sure that all processes are stopped,
By default tries to terminate processes gracefully, but can be
configured to forcefully kill them immediately. See `Terminate Process`
that this keyword uses internally for more details.
Definition at line 606 of file Process.py.
| def robot.libraries.Process.Process.terminate_process | ( | self, | |
handle = None, |
|||
kill = False |
|||
| ) |
Stops the process gracefully or forcefully.
If ``handle`` is not given, uses the current `active process`.
By default first tries to stop the process gracefully. If the process
does not stop in 30 seconds, or ``kill`` argument is given a true value,
(see `Boolean arguments`) kills the process forcefully. Stops also all
the child processes of the originally started process.
Waits for the process to stop after terminating it. Returns a `result
object` containing information about the execution similarly as `Wait
For Process`.
On Unix-like machines graceful termination is done using ``TERM (15)``
signal and killing using ``KILL (9)``. Use `Send Signal To Process`
instead if you just want to send either of these signals without
waiting for the process to stop.
On Windows graceful termination is done using ``CTRL_BREAK_EVENT``
event and killing using Win32 API function ``TerminateProcess()``.
Examples:
| ${result} = | Terminate Process | |
| Should Be Equal As Integers | ${result.rc} | -15 | # On Unixes |
| Terminate Process | myproc | kill=true |
Limitations:
- On Windows forceful kill only stops the main process, not possible
child processes.
Definition at line 560 of file Process.py.
| def robot.libraries.Process.Process.wait_for_process | ( | self, | |
handle = None, |
|||
timeout = None, |
|||
on_timeout = 'continue' |
|||
| ) |
Waits for the process to complete or to reach the given timeout.
The process to wait for must have been started earlier with
`Start Process`. If ``handle`` is not given, uses the current
`active process`.
``timeout`` defines the maximum time to wait for the process. It can be
given in
[http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#time-format|
various time formats] supported by Robot Framework, for example, ``42``,
``42 s``, or ``1 minute 30 seconds``. The timeout is ignored if it is
Python ``None`` (default), string ``NONE`` (case-insensitively), zero,
or negative.
``on_timeout`` defines what to do if the timeout occurs. Possible values
and corresponding actions are explained in the table below. Notice
that reaching the timeout never fails the test.
| = Value = | = Action = |
| continue | The process is left running (default). |
| terminate | The process is gracefully terminated. |
| kill | The process is forcefully stopped. |
See `Terminate Process` keyword for more details how processes are
terminated and killed.
If the process ends before the timeout or it is terminated or killed,
this keyword returns a `result object` containing information about
the execution. If the process is left running, Python ``None`` is
returned instead.
Examples:
| # Process ends cleanly | | |
| ${result} = | Wait For Process | example |
| Process Should Be Stopped | example | |
| Should Be Equal As Integers | ${result.rc} | 0 |
| # Process does not end | | |
| ${result} = | Wait For Process | timeout=42 secs |
| Process Should Be Running | | |
| Should Be Equal | ${result} | ${NONE} |
| # Kill non-ending process | | |
| ${result} = | Wait For Process | timeout=1min 30s | on_timeout=kill |
| Process Should Be Stopped | | |
| Should Be Equal As Integers | ${result.rc} | -9 |
Ignoring timeout if it is string ``NONE``, zero, or negative is new
in Robot Framework 3.2.
Definition at line 498 of file Process.py.
|
private |
Definition at line 325 of file Process.py.
|
private |
Definition at line 326 of file Process.py.
|
static |
Definition at line 322 of file Process.py.
|
static |
Definition at line 319 of file Process.py.
|
static |
Definition at line 320 of file Process.py.
|
static |
Definition at line 321 of file Process.py.