简体   繁体   中英

communication between python programs

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

How to send this daemon a signal from another python program?

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.

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.

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

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

  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM