I'm running under linux and I want python program1 (which will be externally instantiated at some arbitrary time in the future) to be to be able to figure out if python program2 is already running and if so, call a (re-entrant) function in program2 with some arguments. Is there an elegant (preferably python idiomatic) way to do this? --AndyPierce
I don't know the answer, but I'll throw out some ideas. Can you build some sort of protocol on top of os.pipe() or sockets? If you really want to preserve an object interface, maybe you can build on top of Java RMIs using JPython. -- SteveHowell
Oh, also check out http://www.fnorb.org/ (CORBA 2.0 ORB written in Python). I can vouch that I got simple apps up and talking with this three years ago, and that was before I knew a lick of Python. I haven't used it recently, though. -- SteveHowell
Perhaps the simplest way is Pyro, PythonRemoteObjects? - see http://pyro.sourceforge.net/
If by "externally instantiated" you mean by invoking a second python process, then you can't directly do what you ask (have the second program actually call a function in the first). If you can invoke the second python program as a script called from within the first, it would be trivial. Otherwise resort to some standard RPC such as XML-RPC. --PeterHansen
Take a look at an IPC wrapper for python that I wrote: http://www.theory.org/~mac4/software/ The PyIPC package is at the top of the page. It is pretty raw, but it usefull if you need to send python objects between two python processes, or use a C structure to comunicate info. What you could do in your case would be to open a message queue with program one. Then send messages to it with program two. If program one was never started, or crashed, then the message would simply wait in the queue until it was started again. This requires very little overhead and no complicated packages. Message queues are supplied by the OS, and PyIPC is simply a wrapper of the C functions.My email is on the page if you have any questions. -- Neil Macneale