I want to implement a "bus" over which python processes can communicate. The "bus" B shall run as a python process. Other Python processes C1, C2, ...Cn shall be able to register to the bus by a name. After registration it shall be possible for C1 to send a message to C2 by passing a message to the bus together with the name for C2. The Bus shall then route the message to C2. C2 can receive the message in its own Queue object.
I feel, that the multiprocessing package is somehow suited for such task, but I have no idea how to pass the required message queue of C2 to the BUS process upon registration, because all shared objects must be communicated to BUS upon its creation (args). The only idea I have at the moment is to reserve a pool of message queues and pass that to the BUS process initially.
Is there a better solution for that requirement? Maybe there is a package i dont know...
Thanks
-
How are the bus the chatting processes spawned? You have a "main" script that instantiates the bus and then the other processes?Arcanefoam– Arcanefoam2017年09月17日 18:09:19 +00:00Commented Sep 17, 2017 at 18:09
1 Answer 1
If you want to start all processes (c1,c2,bus) separately. Then you should use FIFOs or Unix Sockets to communicate.
Pipes and Queues in multiprocessing package, applicable only if you can send copy of pipe to child process when you spawn it