Several libraries on one server
One server can serve several libraries, to one or more clients.
Which libraries the server imports
Section titled “Which libraries the server imports”The libraries on the command line are the ones that clients may import:
# Only MyLibrary.robot-jsonrpcremote-server MyLibrary
# MyLibrary and Calculator.robot-jsonrpcremote-server MyLibrary Calculator
# Any library that the server can import.robot-jsonrpcremote-server- With one or more libraries, the server refuses to import any other. A client
that gives no
library_namegets the first of them. - Without libraries, the server imports any library that a client names, and a
client has to give
library_name. - The libraries have to be importable on the server: installed, or in a
directory given with
--pythonpath.
Importing several libraries in a suite
Section titled “Importing several libraries in a suite”A JsonRpcRemote import serves one remote library, as a client of its own,
with its own session and connection. To use two libraries, import
JsonRpcRemote twice and give each import a name of its own with AS: Robot
Framework ignores a second import of a library under the same name with other
arguments. The log then shows the keywords as MyLibrary.Greet and
Calculator.Add:
*** Settings ***Library JsonRpcRemote uri=tcp://127.0.0.1:8271 library_name=MyLibrary... AS MyLibraryLibrary JsonRpcRemote uri=tcp://127.0.0.1:8271 library_name=Calculator... AS Calculator
*** Test Cases ***Keywords Of Both Libraries ${greeting}= Greet World Should Be Equal ${greeting} Hello, World! ${sum}= Add 1 2 Should Be Equal As Integers ${sum} 3The second library adds numbers; MyLibrary is the one from
Getting started:
class Calculator: """Adds numbers."""
def add(self, a: int, b: int) -> int: """Returns the sum of ``a`` and ``b``.""" return a + bOne server serves both libraries:
robot-jsonrpcremote-server --pythonpath . MyLibrary CalculatorThe files are in
docs/examples/several-libraries
in the repository.
One Robot Framework execution for all sessions
Section titled “One Robot Framework execution for all sessions”The server runs the keywords of all its sessions in one Robot Framework execution, and Robot Framework runs one keyword at a time. Keywords of different clients and libraries therefore run one after another, and library imports and the cleanup at the end of a session wait their turn the same way. While a keyword runs, for example one that waits for an application, the other clients of the server wait for it. A keyword that does not return also delays stopping the server; see Stopping the server.
Clients that run in parallel, for example the processes of pabot, therefore wait for each other when they share a server.