FourierFlux
FourierFlux

Reputation: 589

Broadcast message to multiple Multiprocessing processes

I have a Multiprocessing application with a bunch of processes, I want the control thread to broadcast a message to multiple processes. If I used a pipe pair for each there will be a ton of pipes.

Is there a way to send one message to multiple processes at the same time?

Upvotes: 2

Views: 1078

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207345

I think it depends what your actual purpose is in sending the message:

  • if the purpose is to share a value/values amongst the processes, you can use a multiprocessing.Value or a multiprocessing.Array
  • if the purpose is to synchronise the next phase of some processing, you could use a multiprocessing Barrier or Event
  • if you really want to do "Pub/Sub" of lots of messages, you would probably want to use Pub/Sub from Redis or MQTT with mosquitto broker.

Upvotes: 2

Related Questions