Communication between python scripts

Heiko Wundram modelnine at ceosg.de
Tue Mar 1 16:17:33 EST 2005


Am Dienstag, 1. März 2005 21:54 schrieb Chris:
> Is there a preferred method for having different scripts on different
> computers communicate with each other?

You have several options at your disposal.

1) Use mail-communication (like you said, a combination of smtplib and 
poplib/imaplib),

2) have the scripts update web-pages which can be accessed by the other script 
to read status information (a combination of ftplib and urllib2),

3) write a socket server process running on some computer which can be 
connected by both clients to update certain flags which can then be read by 
the other process (see SimpleXMLRPCServer),

4) write both programs so that they spawn an additional thread which runs a 
socket server (e.g. SimpleXMLRPCServer) which can be used to query their 
state from the other process,

5) use some RPC-package like Pyro (http://pyro.sourceforge.net/), 
Twisted+Banana (http://www.twistedmatrix.com/), CORBA, etc.

6) do something else which doesn't come to my mind just now. ;)

You have many options at your disposal, and which of the above options you 
choose will depend largely on what your prerequesites are, such as:

1) Do both machines reside on the same network, or do they need gateways to 
communicate (like a mail server in option 1)?

2) Are you willing to install packages like Pyro which do not belong to the 
stdlib on both computers?

3) Can you run some server process on a machine which is reachable by both 
processes?

4) And anything else which I didn't think of just now... ;)

I'd say, if you aren't constrained in some form, go for Pyro to start with. 
Nice and simple.

-- 
--- Heiko.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050301/7d48b00c/attachment.sig>


More information about the Python-list mailing list