What's the advantage of queues over pipes when

2019-02-04 22:13发布

问题:

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.

回答1:

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.



回答2:

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.