Lightstreamer - Basic Stock-List Demo - Python Client
This project contains a simple Python script that shows a minimal client-side implementation of the Lightstreamer Server Text mode Protocol.
The example provides a very simple version of the Stock-List Demos, where a single subscription to 12 items is submitted. The updates are then formatted and displayed on the console.
The script shows all the basic steps required to establish an interaction to Lightstreamer Server. More specifically, the code comprises these actions:
- Connection to Lightstreamer server and session creation
- Subscription to items with specified fields
- Notification about real time updates
- Unsubscription from items
- Final disconnection
It is important to highlight that the example is not meant to be a complete and robust Lightstreamer Client Python library, but it could be used as a starting point to build more complex interactions with the Lightstreamer server to manage all the possible scenarios included in the protocol.
If you want to install a version of this demo pointing to your local Lightstreamer Server, follow these steps:
- Note that, as prerequisite, the Lightstreamer - Stock- List Demo - Java Adapter has to be deployed on your local Lightstreamer Server instance. Please check out that project and follow the installation instructions provided with it.
- Launch Lightstreamer Server.
- Go to http://python.org/download/ and download the appropriate Python (tested since version 2.6.3) for your OS and follow the instructions to install it on your system. Note that the demo currently can not be launched from IDLE.
You can now run the Python script simply executing the following commands on different OS:
- Windows machines:
start python /path/to/example/stock_list_demo.py
- Linux machines:
or, alternatively, you can make the script executable:
chmod +x /path/to/example/stock_list_demo.py
and then type:
The example is configured to connect to http://push.lightstreamer.com:80, but you can easily change these settings modifying the following line:
lightstreamer_client = LSClient("http://push.lightstreamer.com:80", "DEMO")
to connect to the correct combination of host and port of your Lightstreamer server.
Lightstreamer Adapters Needed by this Demo Client
- Lightstreamer - Stock-List Demos - HTML Clients
- Lightstreamer - Basic Stock-List Demo - jQuery (jqGrid) Client
- Lightstreamer - Stock-List Demo - Dojo Toolkit Client
- Lightstreamer - Basic Stock-List Demo - Java SE (Swing) Client
- Lightstreamer - Basic Stock-List Demo - .NET Client
- Lightstreamer - Stock-List Demos - Flex Clients
Lightstreamer Compatibility Notes
- Compatible with Lightstreamer server since version 6.0.
- For Lightstreamer Allegro (+ Generic Client API support), Presto, Vivace.
- For a version of this example compatible with Lightstreamer server version 5.1.2, please refer to this tag.