ipc pickle
Gerson Kurz
gerson.kurz at t-online.de
Mon Feb 25 14:19:16 EST 2002
More information about the Python-list mailing list
Mon Feb 25 14:19:16 EST 2002
- Previous message (by thread): ipc pickle
- Next message (by thread): ipc pickle
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 25 Feb 2002 10:41:53 -0800, hugomartires at hotmail.com (Hugo Martires) wrote: >This only receive twice. >If i need to receive more than twice that is a problem. >See this: ... >I want to send a big vector it's size could be more or less than 8000. >The client to receive the entire vector must receive several times >since BUFFER SIZE it's not so big. (do you know it's maximum value ?) >So the server send : ok, you asked for it, you got it. Download http://p-nand-q.com/python/rpcsys.zip Its *slow* (well, compared to the ipc-test), but it works. Its stripped down from something bigger, so it might contain a "legacy" thing or two; it might even have a bug. Its not yet very well documented, but here are some hints: - your problem is that the socket blocks when its buffer is full. Since you have a single-threaded app, the data is never read, and thus you block forever. Because it was single-threaded, no actual IPC was ever involved, so the time measured is not like "real" values. - a real life IPC system consists of at least 2 procs, so, in the archive you have test-server.py and test-client.py - edit test-server.py's portnum to suit your needs (defaults to 8000 because many PFWs allow that). - class RpcServer handles connections from multiple clients and starts a dedicated thread for each connection - class RpcServerConnection handles a connection - class RpcServerInterface is a simple python class that implements the interface you want to make available by RPC. In this example: # this is the servers' RPC interface class RpcServerInterface(RpcServerConnection): def test(self,argument): return len(argument) it exposes just one function, "test", that has one argument, a list. This is the only class you need to care about! - start test-server.py - edit test-client.py's portnum to suit your needs (defaults to 8000 because many PFWs allow that). - RpcClientThread implements a connection to a server (each client is connected to one server only in this modell) - this class has to implement stubs for functions exposed by the server. For our test function, the stub reads def test(self,arguments): return self.RpcDispatch('test',(arguments,)) How about a more complicated example? Say, our RPC server exports this function: def GetCashUnits(self,a,b,c): print "GetCashUnits() called", a,b,c return [1,2,3,4] A function that gets three parameters and returns a list. The stub would have to read def GetCashUnits(self,a,b,c): return self.RpcDispatch('GetCashUnits',(a,b,c)) You get the idea. Once you connect to the server you simply call these functions, and get a sync return value, too. LIMITATIONS: Return Values must be < 1024 bytes as of now, but that would be easy to change. (My return values are much smaller).
- Previous message (by thread): ipc pickle
- Next message (by thread): ipc pickle
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list