What is a good way to communicate between two separate Python runtimes? Things tried:
- reading/writing on named pipes e.g.
os.mkfifo(feels hacky) dbusservices (worked on desktop, but too heavyweight for headless)- sockets (seems too low-level; surely there’s a higher level module to use?)
My basic requirement is to be able to run python listen.py like a daemon, able to receive messages from python client.py. The client should just send a message to the existing process and terminate, with return code 0 for success and nonzero for failure (i.e. a two-way communication will be required.)
The
multiprocessinglibrary provides listeners and clients that wrap sockets and allow you to pass arbitrary python objects.Your server could listen to receive python objects:
Your client could send commands as objects: