简体   繁体   English

在进程之间进行通信时,队列优于管道的优势是什么?

[英]What's the advantage of queues over pipes when communicating between processes?

What would be the advantage(s) (if any) of using 2 Queues over a Pipe to communicate between processes? 管道上使用2个队列在进程之间进行通信的优点(如果有的话)是什么?

I am planning on using the multiprocessing python module. 我打算使用multiprocessing python模块。

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. 队列的抽象级别也比管道更高,这在您的特定情况下可能是也可能不是优势。

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. 希望这会有所帮助,最好的问候,汤姆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM