I am writing a Python program for which I am considering a local client-server model, but I am struggling to find the best way for the server to communicate with the client (s). A simple, canned solution would be better - I'm not going to reinvent the wheel. Here are my needs for this program:
- Running on linux
- The server and clients are on the same system, so I do not need to go through the network.
- A delay that is unlikely to annoy the interactive user.
- Multiple clients can connect to the same server.
- Clients are launched independently of the server and can connect / disconnect at any time.
- The number of customers is measured in dozens; I do not need to scale very high.
- Customers can come in several different flavors:
- Stream Readers - Reads a continuous stream of data (in practice, this is all text).
- State reader - reads status information, which is updated every time.
- Writers - sends some data to the server, each time receives a response.
Client Type 1 seems simple enough; it is a unidirectional silent pipe. Client type 2 is a little more interesting. I want to avoid just polling the server to periodically check for new data, as this would add a noticeable delay to the user. The server must somehow signal to all and only the relevant clients when the status information is updated so that the client can receive the updated status from the server. Client Type 3 must be bidirectional; it will send the user data to the server and get some kind of response after each send.
I looked at the Python IPC page ( http://docs.python.org/2/library/ipc.html ), but I don't think any of these solutions are suitable for my needs. The subprocess module is completely inappropriate, and everything else is a bit lower level than we would like.
A similar question Effective Python for Python IPC is not quite the same; I donโt need to pass Python objects, I donโt particularly care about the processor efficiency for the number of clients that I will have, I only care about Linux, and none of the answers to this question will especially help me.
Update:
I canโt accept the answer, which simply points me to the framework / library / module / tool, without actually explaining how it can be used for my three different relations between the server and the client. If you say, "All of this can be done using named pipes!" I need to ask: "How?" Code snippets would be ideal, but a high-level solution description may also work.
user108471
source share