Creating a server

From Python

This example shows how to create a server to accept new connections.

import fusionsc as fsc

Serving an object via a network connection is a two-step process.

As a first step, the object to be served needs to be obtained. Generally, this is fsc.backends.localBackend(), but remote backends, e.g. obtained via fsc.remote.connect, can be served as well.

The second step is then the actual serving, which is performed with the fsc.remote.serve method. Optionally, a specific port can be requested. If no port is provided, the operating system will select a free port. The returned object can be used to obtain the actual port, and also to drain / stop the server in the end.

openPort = fsc.remote.serve(fsc.backends.localBackend(), port = 12345)
openPort.getPort()
C:\Daten\repos\fsc\src\python\fusionsc\_api_markers.py:7: UserWarning: The function {f.__module__}.{f.__qualname__} has not yet been properly tested. Please report any errors you find.
  warnings.warn("The function {f.__module__}.{f.__qualname__} has not yet been properly tested. Please report any errors you find.")
C:\Daten\repos\fsc\src\python\fusionsc\remote.py:63: UserWarning: Currently, the fusionsc.remove.serve function caused spurious memory errors in tests. The implementation will need a review
  warnings.warn("Currently, the fusionsc.remove.serve function caused spurious memory errors in tests. The implementation will need a review")
12345
# This method completes once there are no connections left
openPort.drain()
# This method stops the listening
openPort.stopListening()

Standalone

Besides| the possibility to serve a python-exposed server instance, FusionSC also comes with a stand-alone multi- tool executable ‘fusionsc’, available for both Linux and Windows. Among other things, it ships with a server that can be configured from a YAML configuration and is highly portable. It can be launched directly from the command line.

fusionsc server --port 12345