Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect two daemons in python

What is the best way to connect two daemons in Python?

I have daemon A and B. I'd like to receive data generated by B in A's module (maybe bidirectional). Both daemons support plugins, so I'd like to shut communication in plugins. What's the best and cross-platform way to do that?

I know few mechanisms from low-level solutions - shared memory (C/C++), linux pipe, sockets (TCP/UDP), etc. and few high-level - queue (JMS, Rabbit), RPC.

Both daemons should run on the same host, but obviously better approach is to abstract from connection type.

What are typical solutions/libraries in python? I'm looking for an elegant and lightweight solution. I don't need external server, just two processes talking with each other.

What should I use in python to do that?

like image 238
Simon Avatar asked Nov 03 '22 21:11

Simon


1 Answers

You can use sockets for process communication: http://docs.python.org/howto/sockets.html

Also remote procedure calls suits for that: Python XML RPC http://docs.python.org/library/xmlrpclib.html or Google Protobuf http://code.google.com/p/protobuf/ https://developers.google.com/protocol-buffers/docs/pythontutorial

like image 64
Dmitry Trofimov Avatar answered Nov 13 '22 16:11

Dmitry Trofimov