Skip to content
JsonRpcRemote is in pre-alpha and under active development. This documentation describes the development version on main, which may differ from the latest release, and more features are coming: see Status and roadmap.

Several libraries on one server

One server can serve several libraries, to one or more clients.

The libraries on the command line are the ones that clients may import:

Terminal window
# 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_name gets 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.

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:

two-libraries.robot
*** Settings ***
Library JsonRpcRemote uri=tcp://127.0.0.1:8271 library_name=MyLibrary
... AS MyLibrary
Library 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} 3

The second library adds numbers; MyLibrary is the one from Getting started:

Calculator.py
class Calculator:
"""Adds numbers."""
def add(self, a: int, b: int) -> int:
"""Returns the sum of ``a`` and ``b``."""
return a + b

One server serves both libraries:

Terminal window
robot-jsonrpcremote-server --pythonpath . MyLibrary Calculator

The 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.