tags:

views:

87

answers:

4

I have a python program that is running as daemon on Linux

I need some how send this program a signal from another python program What should I do in both this programs ?

A: 
  • The daemon could have an open (network) socket, where it accepts commands.
  • It could monitor changes in a file.

Any other kind of signalling is possible, but these would probably be the most common.

relet
thanks, know about that.. but would be to complex for my needs.. looking for some simplier way (maybe with signal module)..
Pydev UA
+2  A: 

Have you tried reading through the docs on interprocess communication in Python? Here is a link:

http://docs.python.org/library/ipc.html

wshato
+1  A: 

Use os.kill to send signals. The signals are defined in the signal module. You'll just need to get the pid of the daemon in some way.

One more thing - you can use the signal module to register signal handlers as well.

Jeremy Brown
A: 

If you need something more sophisticated than simple signals, consider using an RPC library like PYRO. The advantage of this is that you can use it even if you have to move your processes to separate servers.

Or, if you mainly target Linux systems, then look at using DBUS instead. There is a python library and it is now even supported on Windows.

Michael Dillon