nspyre.data.server
The nspyre data server transports arbitrary python objects over a TCP/IP socket
to a set of local or remote network clients, and keeps those objects up to date
as they are modified. For each data set on the data server, there is a single
data DataSource
, and a set of data
DataSink
. The source pushes data to
the data server and each of the sinks pops data from the data server.
Objects are serialized by the source then pushed to the server. Each sink
receives a copy of the serialized objects, then deserializes them locally. If
the user makes use of “Streaming” objects such as the
StreamingList
, the source
will only serialize the operations that have been performed on the streaming
object since the last serialization. The sink can then reconstruct the pushed
data using a local copy of the last version of the object, and the diff
received from the data server. This is more efficient when data sets start
becoming larger and serialization performance is a bottleneck.
The data server can be started using the command-line interface, e.g.:
$ nspyre-dataserv -p 12345
Module Contents
Classes
The server has a set of DataSet objects. Each has 1 data source, and any number of |
Attributes
Default port to host the data server on. |
- nspyre.data.server.DATASERV_PORT = 30101
Default port to host the data server on.
- class nspyre.data.server.DataServer(port=DATASERV_PORT)
The server has a set of DataSet objects. Each has 1 data source, and any number of data sinks. Pickled object data from the source is received on its socket, then transferred to the FIFO of every sink. The pickle is then sent out on the sink’s socket. E.g.:
self.datasets = { 'dataset1' : _DataSet( socket (source) ----------> FIFO ------> socket (sink 1) | ------> FIFO ------> socket (sink 2) ), 'dataset2' : _DataSet( socket (source) ----------> FIFO ------> socket (sink 1) | ------> FIFO ------> socket (sink 2) | ------> FIFO ------> socket (sink 3) | ------> FIFO ------> socket (sink 4) ), ... }
- Parameters:
port (int) – TCP/IP port of the data server
- serve_forever()
Run the asyncio event loop - ayncio requires this be run in the main thread if processes are to be spawned from the event loop. See https://docs.python.org/3/library/asyncio-dev.html.
- stop()
Stop the asyncio event loop.