Process intercommunication

Grzegorz Dostatni grzegorz at ugrad.cs.ualberta.ca
Mon Nov 5 08:29:30 EST 2001


For interprocess communications You have a couple of options. If A can
start B at a proper time You could solve Your problem with pipes. (using
popen I believe). If B is started differently, You could look into
signals to catch A's attention.  The easisest thing though it so make A a
server and make B connect on a given port.
An example of a server and a client is at:
http://www.python.org/doc/current/lib/socket-example.html

It is quite possible to have a client and a server on the same machine. If
You're not going to have more than 10 processes trying to access Your
server (at a time) I'd recommend using the threading module to make things
a bit easier on Yourself. (watch out for mutual exclusion though ;-) ).

A reading list (assuming You'd like to go with sockets)

http://www.python.org/doc/current/lib/module-socket.html (socket module)
http://www.python.org/doc/current/lib/module-thread.html (thread module)
http://www.python.org/doc/current/lib/module-threading.html (threading
module)

The last one is a higher level  version of the second one.

Hope this helps.
Greg




More information about the Python-list mailing list