views:

249

answers:

2

What would be the advantage(s) (if any) of using 2 Queues over a Pipe to communicate between processes?

I am planning on using the multiprocessing python module.

+6  A: 

The big win is that queues are process- and thread- safe. Pipes are not: if two different processes try to read from or write to the same end of a pipe, bad things happen. Queues are also at a somewhat higher level of abstraction than pipes, which may or may not be an advantage in your specific case.

John Feminella
Indeed; the multiprocessing queue is implemented as Pipes protected with Locks.
Jonathan Feinberg
+1: excellent point.
jldupont
+1 Jonathan, that's very cool. Learned something new.
John Feminella
@John Feminella: Jonathan's comment is related to a previous question: http://stackoverflow.com/questions/2275108/python-multi-processing-queue-is-putting-independent-from-getting/
jldupont
+3  A: 

Queues hold the messages and retains them until the next time the queue is active and pushes it through...regardless if the pipe or connection is broken...with a pipe/connection, its goodbye to the message with an error...

Hope this helps, Best regards, Tom.

tommieb75
+1: good point. thanks!
jldupont
@jldupont: no prob! :)
tommieb75