passing data to a daemon

Nils O. Selåsdal noselasd at frisurf.no
Sun Oct 5 09:33:38 EDT 2003


In article <mailman.1065304328.9617.python-list at python.org>, Rob Hunter wrote:
> Hi all.
> 
> I want to run a Python daemon that manages a "to-do" queue.  I want it 
> so that the daemon is always running, where its running consists of 
> looking at the queue to see if it has any jobs, and if it does, remove 
> the job from the queue and "do the job".
> 
> This all seems quite doable using the synchronized Queue.py module and 
> this page 
> (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012) which 
> describes writing a daemon in Python.
> 
> My problem is: how will I submit jobs to the queue?  The issue is that 
> jobs are generated by users of, say, the operating system, so they 
> aren't a part of the daemon process.  Ideally, I want a way of making a 
> function call to the daemon process *from outside the daemon process*.
> 
> For example, say my daemon has the function in it "addToQueue".  I'd 
> like to write a totally separate piece of Python code that calls this 
> function inside the *running* daemon.
> 
> I suppose I could use files with locking as an interface, but there's 
> got to be a better way.
Files are one way. Sockets another. Make it listen on a socket
and accept commands from it, write a client that connects
to and send commands/data to it. If you're on *nix, use
unix sockets. Higher level API's over sockets can also be used,
e.g. xml-rpc or corba.





More information about the Python-list mailing list